예제 #1
0
 def defer(self, f, *args, **kwargs):
     self._queue.append((f, args, kwargs))
     if not self._working:
         self._working = True
         if self._defer_func:
             self._defer_func(self._pump)
         else:
             Tasklet.defer(self._pump)
예제 #2
0
 def defer(self, f, *args, **kwargs):
     self._queue.append((f, args, kwargs))
     if not self._working:
         self._working = True
         if self._defer_func:
             self._defer_func(self._pump)
         else:
             Tasklet.defer(self._pump)
예제 #3
0
 def run(self):
     Tasklet.set_current_timeout(self._worker_timeout, self._worker_timeout_relative)
     while True:
         try:
             f, args, kwargs = self._queue.popleft(True, TIMEOUT_NEVER)
             f(*args, **kwargs)
         except Exception:
             self.log.exception("in taskpool worker")
             Tasklet.sleep(1.0)
예제 #4
0
 def run(self):
     Tasklet.set_current_timeout(self._worker_timeout,
                                 self._worker_timeout_relative)
     while True:
         try:
             f, args, kwargs = self._queue.popleft(True, TIMEOUT_NEVER)
             f(*args, **kwargs)
         except Exception:
             self.log.exception("in taskpool worker")
             Tasklet.sleep(1.0)
예제 #5
0
 def run(self):
     while True:
         try:
             f, args, kwargs = self._queue.popleft(True, TIMEOUT_NEVER)
             f(*args, **kwargs)
         except TaskletExit:
             raise
         except:
             self.log.exception("in taskpool worker")
             Tasklet.sleep(1.0)
예제 #6
0
 def __init__(self):
     self._queue = Deque()
     self._workers = []
     for i in range(self.INIT_WORKERS):
         self._add_worker()
     self._adjuster = Tasklet.interval(1.0, self._adjust, daemon = True)()
     self._queue_len = 0.0
예제 #7
0
 def __init__(self, worker_timeout = TIMEOUT_NEVER, worker_timeout_relative = True):
     self._queue = Deque()
     self._workers = []
     self._worker_timeout = worker_timeout
     self._worker_timeout_relative = worker_timeout_relative
     for i in range(self.INIT_WORKERS):
         self._add_worker()
     self._adjuster = Tasklet.interval(1.0, self._adjust, daemon = True)()
     self._queue_len = 0.0
예제 #8
0
 def __init__(self,
              worker_timeout=TIMEOUT_NEVER,
              worker_timeout_relative=True):
     self._queue = Deque()
     self._workers = []
     self._worker_timeout = worker_timeout
     self._worker_timeout_relative = worker_timeout_relative
     for i in range(self.INIT_WORKERS):
         self._add_worker()
     self._adjuster = Tasklet.interval(1.0, self._adjust, daemon=True)()
     self._queue_len = 0.0
예제 #9
0
 def _add_worker(self):
     self._workers.append(Tasklet.new(self.run, daemon=True)())
     self.log.debug('added worker, #now: %s', len(self._workers))
예제 #10
0
 def _add_worker(self):
     self._workers.append(Tasklet.new(self.run, daemon = True)())
     self.log.debug('added worker, #now: %s', len(self._workers))