コード例 #1
0
    def _monitor_event_servers(self):
        def wrapped_func():
            servers = self._get_event_servers()
            self._update_event_servers(servers)

        callInGreenThread(wrapped_func)
        return KeepRunning
コード例 #2
0
 def start(self):
     if self._started:
         raise RuntimeError("worker has already been started")
     if not threadable.isInIOThread():
         raise RuntimeError("worker can only be started in the IO thread")
     self._started = True
     callInGreenThread(self.__run__)
コード例 #3
0
ファイル: sipthor.py プロジェクト: AGProjects/sylkserver
    def _monitor_event_servers(self):
        def wrapped_func():
            servers = self._get_event_servers()
            self._update_event_servers(servers)

        callInGreenThread(wrapped_func)
        return KeepRunning
コード例 #4
0
 def wrapper(*args, **kw):
     event = coros.event()
     def wrapped_func():
         try:
             result = func(*args, **kw)
         except:
             event.send_exception(*sys.exc_info())
         else:
             event.send(result)
     if threadable.isInIOThread():
         callInGreenThread(wrapped_func)
     else:
         from twisted.internet import reactor
         reactor.callFromThread(callInGreenThread, wrapped_func)
     return event
コード例 #5
0
def call_in_green_thread(func, *args, **kw):
    if threadable.isInIOThread():
        callInGreenThread(func, *args, **kw)
    else:
        from twisted.internet import reactor
        reactor.callFromThread(callInGreenThread, func, *args, **kw)