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


Python POLLER.unset_writable方法代码示例

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


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

示例1: handle_write

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import unset_writable [as 别名]
 def handle_write(self):
     POLLER.unset_writable(self)
     if not utils_net.isconnected(self.endpoint, self.sock):
         self._connection_failed()
         return
     deferred = Deferred()
     deferred.add_callback(self._handle_connect)
     deferred.add_errback(self._handle_connect_error)
     deferred.callback(utils.ticks())
开发者ID:EverlastingFire,项目名称:neubot,代码行数:11,代码来源:connector.py

示例2: _connection_failed

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import unset_writable [as 别名]
 def _connection_failed(self):
     ''' Failed to connect first available epnt '''
     if self.sock:
         POLLER.unset_writable(self)
         self.sock = None  # MUST be below unset_writable()
     if not self.epnts:
         self.aterror.callback_each_np(self)
         return
     self._connect()
开发者ID:EverlastingFire,项目名称:neubot,代码行数:11,代码来源:connector.py

示例3: handle_write

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

        #
        # Deal with the case where send() is blocked by recv(), that happens
        # when we are using SSL and recv() returned WANT_WRITE.  In the common
        # case, this costs just one extra if in the fast path.
        #
        if self.send_blocked:
            logging.debug('stream: handle_write() => handle_read()')
            POLLER.set_readable(self)
            if not self.send_octets:
                POLLER.unset_writable(self)
            self.send_blocked = False
            self.handle_read()
            return

        status, count = self.sock.sosend(self.send_octets)

        #
        # 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 count > 0:
            self.bytes_out += count

            if count == len(self.send_octets):
                POLLER.unset_writable(self)
                self.send_octets = EMPTY_STRING
                self.send_complete(self)
                return

            if count < len(self.send_octets):
                self.send_octets = six.buff(self.send_octets, count)
                return

            raise RuntimeError('stream: invalid count')

        if status == WANT_WRITE:
            return

        if status == WANT_READ:
            logging.debug('stream: blocking recv()')
            POLLER.unset_writable(self)
            POLLER.set_readable(self)
            self.recv_blocked = True
            return

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

        if status == SUCCESS and count < 0:
            raise RuntimeError('stream: negative count')

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

示例4: handle_write

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import unset_writable [as 别名]
 def handle_write(self):
     POLLER.unset_writable(self)
     self.handshake()
开发者ID:EverlastingFire,项目名称:neubot,代码行数:5,代码来源:sslstream.py


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