Exemplo n.º 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
Exemplo n.º 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__)
Exemplo n.º 3
0
    def _monitor_event_servers(self):
        def wrapped_func():
            servers = self._get_event_servers()
            self._update_event_servers(servers)

        callInGreenThread(wrapped_func)
        return KeepRunning
Exemplo n.º 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
Exemplo n.º 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)