def test_make_coro(): test_func = lambda(x, y): (x, y) for x in xrange(1000): a = coro.new(test_func, 0, 1) # Unspawned threads aren't able to clean up their all_threads reference del coro.all_threads[a.thread_id()] del a coros = map(lambda x, test_func=test_func: coro.new(test_func, x, 1), range(1000)) for x in coros: # Unspawned threads aren't able to clean up their all_threads reference del coro.all_threads[x.thread_id()] del coros
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, _co=None): if group is not None: raise AssertionError("group must be None for now") if kwargs is None: kwargs = {} self.__target = target self.__args = args self.__kwargs = kwargs if _co is None: self.__co = coro.new(self.__bootstrap) else: self.__co = _co self.ident = self.__co.id if name: self.__co.set_name(name)
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, _co=None): if group is not None: raise AssertionError('group must be None for now') if kwargs is None: kwargs = {} self.__target = target self.__args = args self.__kwargs = kwargs if _co is None: self.__co = coro.new(self.__bootstrap) else: self.__co = _co self.ident = self.__co.id if name: self.__co.set_name(name)
def handle_request (self, request): sid, c = self.find_session (request) # The sid=='None' test is temporary hack, can probably remove it if (not sid) or (sid=='None'): sid = self.gen_session_id() if c and c.isAlive(): # is c already running? # hack, must grok this coro.schedule (c, request) request._done = 1 else: # login c = coro.new (self.function, self, request, sid) # Wdy, DD-Mon-YYYY HH:MM:SS GMT expires = time.strftime ('%a, %d-%b-%Y 00:00:00 GMT', time.gmtime (int (time.time()) + self.expires_delta)) request['Set-Cookie'] = 'session=%s; path=/; expires=%s' % (sid, expires) # hack, must grok this request._done = 1 c.start()