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


Python protocol.isDispatchThread函数代码示例

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


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


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