Public Member Functions | |
def | __init__ |
def | do_multiprocessing |
def | do_threaded |
def | __getattr__ |
def | __del__ |
def | shutdown |
def | abort |
def | drain_queue |
Private Attributes | |
_proctype |
Asynchronous interface to some other object (called "real" below). Any method calls on this object, other than the ones explicitly defined, must have as their first argument a callable object ("callback"). The method name and remaining arguments will be queued to another object running in a different process where it will be interpted and result in calling the method on the real object. The result will be queued back to this interface object where the callback will be called with the result as its argument.
Definition at line 48 of file async.py.
def EventLooper::async::AsyncInterface::__init__ | ( | self, | ||
obj, | ||||
proctype = None | ||||
) |
Definition at line 51 of file async.py.
00063 : 00064 if not obj: 00065 raise ValueError,'Must give a valid object' 00066 self.__dict__['_obj'] = obj 00067 self.__dict__['_count'] = 0 00068 self.__dict__['_callbacks'] = {} 00069 00070 if proctype: 00071 meth = eval ("self.do_%s"%proctype) 00072 meth() return
def EventLooper::async::AsyncInterface::do_multiprocessing | ( | self | ) |
def EventLooper::async::AsyncInterface::do_threaded | ( | self | ) |
Definition at line 83 of file async.py.
00085 : 00086 from multiprocessing import Queue, Process 00087 self.__dict__['_proctype'] = 'multiprocessing' 00088 self.__dict__['_outbox'] = outbox = Queue() 00089 self.__dict__['_inbox'] = inbox = Queue() 00090 self.__dict__['_proc'] = proc = Process(target=async_caller, 00091 args=(self._obj, outbox, inbox)) 00092 proc.start() 00093 return
def EventLooper::async::AsyncInterface::__getattr__ | ( | self, | ||
name | ||||
) |
Definition at line 94 of file async.py.
00095 : 00096 from Queue import Queue 00097 from threading import Thread 00098 self.__dict__['_proctype'] = 'threading' 00099 self.__dict__['_outbox'] = outbox = Queue() 00100 self.__dict__['_inbox'] = inbox = Queue() 00101 self.__dict__['_proc'] = proc = Thread(target=async_caller, 00102 args=(self._obj, outbox, inbox)) 00103 proc.start() 00104 return
def EventLooper::async::AsyncInterface::__del__ | ( | self | ) |
def EventLooper::async::AsyncInterface::shutdown | ( | self | ) |
def EventLooper::async::AsyncInterface::abort | ( | self | ) |
def EventLooper::async::AsyncInterface::drain_queue | ( | self, | ||
depth = None | ||||
) |
Definition at line 124 of file async.py.
00128 : 00129 'Immediately shutdown' 00130 if self._proctype == 'multiproces': 00131 self._proc.terminate() 00132 import sys 00133 sys.exit(0) 00134 return 00135 00136 def drain_queue(self, depth = None): 00137 'Drain queue of at most depth pending results. All if depth=None' 00138 while depth is None or depth > 0: 00139 if depth is not None: depth -= 1 00140 if self._inbox.empty(): #print 'queue empty'