def external_add_task(self, delay, _f, *args, **kwargs): """Schedule the passed function 'func' to be called after 'delay' seconds and pass 'args'. This should be called by threads other than RawServer's thread.""" if delay == 0: return reactor.callFromThread(_f, *args, **kwargs) else: return reactor.callFromThread(reactor.callLater, delay, _f, *args, **kwargs)
def external_add_task(self, delay, _f, *args, **kwargs): """Schedule the passed function 'func' to be called after 'delay' seconds and pass 'args'. This should be called by threads other than RawServer's thread.""" if delay == 0: return reactor.callFromThread(_f, *args, **kwargs) else: return reactor.callFromThread(reactor.callLater, delay, _f, *args, **kwargs)
def run(): global queue while True: df = queue.get() if df is None: break if df.error: try: fdsfs = tasty except: reactor.callFromThread(df.errback, Failure()) else: reactor.callFromThread(df.callback, 'post')
def run(): global queue while True: df = queue.get() if df is None: break if df.error: try: fdsfs = tasty except: reactor.callFromThread(df.errback, Failure()) else: reactor.callFromThread(df.callback, 'post')
def connectionLost(self, reason): _got_result(None) class RecorderFactory(ClientFactory): def clientConnectionFailed(self, connector, reason): _got_result(None) def _resolve(): try: ip = socket.gethostbyname(socket.gethostname()) except socket.error, e: ip = 'unknown' reactor.callFromThread(_got_result, ip) def _finish(ip): global _thread_running _thread_running = False _got_result(ip) def _got_result(ip): global _host_ip global _host_ip_callbacks global _host_ip_cachetime global _thread_running if hasattr(reactor, 'ident'): assert reactor.ident == thread.get_ident()
def connectionLost(self, reason): _got_result(None) class RecorderFactory(ClientFactory): def clientConnectionFailed(self, connector, reason): _got_result(None) def _resolve(): try: ip = socket.gethostbyname(socket.gethostname()) except socket.error, e: ip = 'unknown' reactor.callFromThread(_got_result, ip) def _finish(ip): global _thread_running _thread_running = False _got_result(ip) def _got_result(ip): global _host_ip global _host_ip_callbacks global _host_ip_cachetime global _thread_running if hasattr(reactor, 'ident'): assert reactor.ident == thread.get_ident()