• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python protocol.isDispatchThread函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tcf.protocol.isDispatchThread函数的典型用法代码示例。如果您正苦于以下问题:Python isDispatchThread函数的具体用法?Python isDispatchThread怎么用?Python isDispatchThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: addEventListener

 def addEventListener(self, service, listener):
     assert protocol.isDispatchThread()
     svc_name = str(service)
     listener.svc_name = svc_name
     list = self.event_listeners.get(svc_name) or []
     list.append(listener)
     self.event_listeners[svc_name] = list
开发者ID:eswartz,项目名称:emul,代码行数:7,代码来源:AbstractChannel.py


示例2: _processQueue

 def _processQueue(self):
     assert protocol.isDispatchThread()
     with self._lock:
         for cmd in self._queue:
             service, command, args, kwargs = cmd
             self._invoke(service, command, *args, **kwargs)
         del self._queue[:]
开发者ID:eswartz,项目名称:emul,代码行数:7,代码来源:sync.py


示例3: sendCommand

 def sendCommand(self, service, name, args, listener):
     assert protocol.isDispatchThread()
     if self.state == STATE_OPENING: raise Exception("Channel is waiting for Hello message")
     if self.state == STATE_CLOSED: raise Exception("Channel is closed")
     msg = Message('C')
     msg.service = str(service)
     msg.name = name
     msg.data = args
     channel = self
     class CancelableToken(Token):
         def __init__(self, listener):
             super(CancelableToken, self).__init__(listener=listener)
         def cancel(self):
             assert protocol.isDispatchThread()
             if channel.state != STATE_OPEN: return False
             with channel.out_lock:
                 if msg.is_sent: return False
                 msg.is_canceled = True
             del channel.out_tokens[msg.token.getID()]
             return True
     token = CancelableToken(listener)
     msg.token = token
     self.out_tokens[token.getID()] = msg
     self.addToOutQueue(msg)
     return token
开发者ID:eswartz,项目名称:emul,代码行数:25,代码来源:AbstractChannel.py


示例4: wait

 def wait(self, timeout=None):
     assert not protocol.isDispatchThread()
     with self._lock:
         while self._pending or self._queue:
             self._lock.wait(timeout)
             if timeout:
                 break
开发者ID:wind-river-cdt,项目名称:tcf,代码行数:7,代码来源:sync.py


示例5: sendResult

 def sendResult(self, token, results):
     assert protocol.isDispatchThread()
     if self.state != STATE_OPEN: raise Exception("Channel is closed")
     msg = Message('R')
     msg.data = results
     msg.token = token
     self.addToOutQueue(msg)
开发者ID:eswartz,项目名称:emul,代码行数:7,代码来源:AbstractChannel.py


示例6: __sendCongestionLevel

 def __sendCongestionLevel(self):
     self.local_congestion_cnt += 1
     if self.local_congestion_cnt < 8: return
     self.local_congestion_cnt = 0
     if self.state != STATE_OPEN: return
     timeVal = int(time.time() * 1000)
     if timeVal - self.local_congestion_time < 500: return
     assert protocol.isDispatchThread()
     level = protocol.getCongestionLevel()
     if level == self.local_congestion_level: return
     i = (level - self.local_congestion_level) / 8
     if i != 0: level = self.local_congestion_level + i
     self.local_congestion_time = timeVal
     with self.out_lock:
         msg = None
         if self.out_queue:
             msg = self.out_queue[0]
         if msg is None or msg.type != 'F':
             msg = Message('F')
             self.out_queue.insert(0, msg)
             self.out_lock.notify()
         data = "%i\0" % self.local_congestion_level
         msg.data = data
         msg.trace = self.trace_listeners
         self.local_congestion_level = level
开发者ID:eswartz,项目名称:emul,代码行数:25,代码来源:AbstractChannel.py


示例7: getRemoteService

 def getRemoteService(self, cls_or_name):
     assert protocol.isDispatchThread()
     assert self.state != STATE_OPENING
     if type(cls_or_name) == types.StringType:
         return self.remote_service_by_name.get(cls_or_name)
     else:
         return self.remote_service_by_class.get(cls_or_name)
开发者ID:eswartz,项目名称:emul,代码行数:7,代码来源:AbstractChannel.py


示例8: getData

 def getData(self):
     """
     @return cached data object.
     Note: It is prohibited to call this method when cache is not valid.
     """
     assert protocol.isDispatchThread()
     assert self.__valid
     return self.__data
开发者ID:wind-river-cdt,项目名称:tcf,代码行数:8,代码来源:cache.py


示例9: cancel

 def cancel(self):
     if not protocol.isDispatchThread():
         protocol.invokeLater(self.cancel)
         return
     with self._lock:
         for cmd in self._pending.values():
             cmd.token.cancel()
         del self._queue[:]
开发者ID:eswartz,项目名称:emul,代码行数:8,代码来源:sync.py


示例10: dispose

 def dispose(self):
     assert protocol.isDispatchThread()
     id = self.getID()
     assert id
     peers = protocol.getLocator().getPeers()
     assert peers.get(id) == self
     del peers[id]
     self.sendPeerRemovedEvent()
开发者ID:eswartz,项目名称:emul,代码行数:8,代码来源:peer.py


示例11: cancel

 def cancel(self):
     assert protocol.isDispatchThread()
     if channel.state != STATE_OPEN: return False
     with channel.out_lock:
         if msg.is_sent: return False
         msg.is_canceled = True
     del channel.out_tokens[msg.token.getID()]
     return True
开发者ID:eswartz,项目名称:emul,代码行数:8,代码来源:AbstractChannel.py


示例12: terminate

 def terminate(self, error):
     assert protocol.isDispatchThread()
     if self.state == STATE_CLOSED: return
     try:
         self.__sendEndOfStream(500)
     except Exception as x:
         if not error: error = x
     self._close(error)
开发者ID:eswartz,项目名称:emul,代码行数:8,代码来源:AbstractChannel.py


示例13: close

 def close(self):
     assert protocol.isDispatchThread()
     if self.state == STATE_CLOSED: return
     try:
         self.__sendEndOfStream(10000)
         self._close(None)
     except Exception as x:
         self._close(x)
开发者ID:eswartz,项目名称:emul,代码行数:8,代码来源:AbstractChannel.py


示例14: sendEvent

 def sendEvent(self, service, name, args):
     assert protocol.isDispatchThread()
     if not (self.state == STATE_OPEN or self.state == STATE_OPENING and isinstance(service, locator.LocatorService)):
         raise Exception("Channel is closed")
     msg = Message('E')
     msg.service = str(service)
     msg.name = name
     msg.data = args
     self.addToOutQueue(msg)
开发者ID:eswartz,项目名称:emul,代码行数:9,代码来源:AbstractChannel.py


示例15: cancel

 def cancel(self):
     assert protocol.isDispatchThread()
     with self._lock:
         if self.isDone(): return False
         self.__canceled = True
         self.__error = Exception("Canceled")
         if self.__channel:
             self.__channel.removeChannelListener(self.__channel_listener)
         self._lock.notifyAll()
     return True
开发者ID:eswartz,项目名称:emul,代码行数:10,代码来源:task.py


示例16: __init__

 def __init__(self, attrs):
     super(AbstractPeer, self).__init__(attrs)
     assert protocol.isDispatchThread()
     id = self.getID()
     assert id
     peers = protocol.getLocator().getPeers()
     if isinstance(peers.get(id), RemotePeer):
         peers.get(id).dispose()
     assert id not in peers
     peers[id] = self
     self.sendPeerAddedEvent()
开发者ID:eswartz,项目名称:emul,代码行数:11,代码来源:peer.py


示例17: _waitForCommand

 def _waitForCommand(self, token, timeout=None):
     assert not protocol.isDispatchThread()
     with self._lock:
         while token.id in self._pending:
             self._lock.wait(timeout)
             if timeout: break
         else:
             if self._queue:
                 self._lock.wait(timeout)
                 while token.id in self._pending:
                     self._lock.wait(timeout)
                     if timeout: break
开发者ID:eswartz,项目名称:emul,代码行数:12,代码来源:sync.py


示例18: removeEventListener

 def removeEventListener(self, service, listener):
     assert protocol.isDispatchThread()
     svc_name = str(service)
     list = self.event_listeners.get(svc_name)
     if not list: return
     for i in range(len(list)):
         if list[i] is listener:
             if len(list) == 1:
                 del self.event_listeners[svc_name]
             else:
                 del list[i]
             return
开发者ID:eswartz,项目名称:emul,代码行数:12,代码来源:AbstractChannel.py


示例19: done

 def done(self, result):
     with self._lock:
         assert protocol.isDispatchThread()
         if self.__canceled: return
         assert not self.__is_done
         assert not self.__error
         assert self.__result is None
         self.__result = result
         self.__is_done = True
         if self.__channel:
             self.__channel.removeChannelListener(self.__channel_listener)
         self._lock.notifyAll()
开发者ID:eswartz,项目名称:emul,代码行数:12,代码来源:task.py


示例20: reset

 def reset(self, data=None):
     """
     Force cache to become valid, cancel pending data retrieval if data is provided.
     @param data - up-to-date data object (optional)
     """
     assert protocol.isDispatchThread()
     if data is not None and self._command is not None:
         self._command.cancel()
         self._command = None
     if not self.__disposed:
         self.__data = data
         self.__error = None
         self.__valid = True
     self.post()
开发者ID:wind-river-cdt,项目名称:tcf,代码行数:14,代码来源:cache.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python protocol.log函数代码示例发布时间:2022-05-27
下一篇:
Python protocol.invokeLater函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap