当前位置: 首页>>代码示例>>Python>>正文


Python POLLER.set_writable方法代码示例

本文整理汇总了Python中neubot.poller.POLLER.set_writable方法的典型用法代码示例。如果您正苦于以下问题:Python POLLER.set_writable方法的具体用法?Python POLLER.set_writable怎么用?Python POLLER.set_writable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neubot.poller.POLLER的用法示例。


在下文中一共展示了POLLER.set_writable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _connect

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import set_writable [as 别名]
 def _connect(self):
     ''' Connect first available epnt '''
     sock = utils_net.connect(self.epnts.popleft(), self.prefer_ipv6)
     if sock:
         self.sock = sock
         self.timestamp = utils.ticks()
         POLLER.set_writable(self)
     else:
         self._connection_failed()
开发者ID:EverlastingFire,项目名称:neubot,代码行数:11,代码来源:connector.py

示例2: handle_read

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import set_writable [as 别名]
    def handle_read(self):

        #
        # Deal with the case where recv() is blocked by send(), that happens
        # when we are using SSL and write() returned WANT_READ.  In the common
        # case, this costs just one extra if in the fast path.
        #
        if self.recv_blocked:
            logging.debug('stream: handle_read() => handle_write()')
            POLLER.set_writable(self)
            if self.recv_bytes <= 0:
                POLLER.unset_readable(self)
            self.recv_blocked = False
            self.handle_write()
            return

        status, octets = self.sock.sorecv(self.recv_bytes)

        #
        # Optimisation: reorder if branches such that the ones more relevant
        # for better performance come first.  Testing in early 2011 showed that
        # this arrangement allows to gain a little more speed.  (And the code
        # is still readable.)
        #

        if status == SUCCESS and octets:
            self.bytes_in += len(octets)
            self.recv_bytes = 0
            POLLER.unset_readable(self)
            self.recv_complete(self, octets)
            return

        if status == WANT_READ:
            return

        if status == WANT_WRITE:
            logging.debug('stream: blocking send()')
            POLLER.unset_readable(self)
            POLLER.set_writable(self)
            self.send_blocked = True
            return

        if status == SUCCESS and not octets:
            logging.debug('stream: EOF')
            self.eof = True
            POLLER.close(self)
            return

        if status == CONNRST and not octets:
            logging.debug('stream: RST ')
            self.conn_rst = True
            POLLER.close(self)
            return

        raise RuntimeError('stream: invalid status')
开发者ID:EverlastingFire,项目名称:neubot,代码行数:57,代码来源:stream.py

示例3: send

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import set_writable [as 别名]
    def send(self, send_octets, send_complete):
        ''' Async send() '''

        if self.isclosed:
            raise RuntimeError('stream: send() on a closed stream')
        if self.send_octets:
            raise RuntimeError('stream: already send()ing')

        self.send_octets = send_octets
        self.send_complete = send_complete

        if self.send_blocked:
            logging.debug('stream: send() is blocked')
            return

        POLLER.set_writable(self)
开发者ID:EverlastingFire,项目名称:neubot,代码行数:18,代码来源:stream.py

示例4: handshake

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import set_writable [as 别名]
 def handshake(self):
     ''' Async SSL handshake '''
     try:
         self.opaque.sock.sock.do_handshake()
     except ssl.SSLError:
         exception = sys.exc_info()[1]
         if exception.args[0] == ssl.SSL_ERROR_WANT_READ:
             POLLER.set_readable(self)
         elif exception.args[0] == ssl.SSL_ERROR_WANT_WRITE:
             POLLER.set_writable(self)
         else:
             raise
     else:
         stream = self.opaque
         self.opaque = None
         stream.atconnect.callback(stream)
开发者ID:EverlastingFire,项目名称:neubot,代码行数:18,代码来源:sslstream.py


注:本文中的neubot.poller.POLLER.set_writable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。