|
@@ -43,7 +43,8 @@ class Pool(bootsteps.StartStopComponent):
|
|
|
name = 'worker.pool'
|
|
|
requires = ('queues', )
|
|
|
|
|
|
- def __init__(self, w, autoscale=None, no_execv=False, **kwargs):
|
|
|
+ def __init__(self, w, autoscale=None, autoreload=None,
|
|
|
+ no_execv=False, **kwargs):
|
|
|
if isinstance(autoscale, basestring):
|
|
|
max_c, _, min_c = autoscale.partition(',')
|
|
|
autoscale = [int(max_c), min_c and int(min_c) or 0]
|
|
@@ -54,6 +55,7 @@ class Pool(bootsteps.StartStopComponent):
|
|
|
w.no_execv = no_execv
|
|
|
if w.autoscale:
|
|
|
w.max_concurrency, w.min_concurrency = w.autoscale
|
|
|
+ self.autoreload_enabled = autoreload
|
|
|
|
|
|
def on_poll_init(self, pool, hub):
|
|
|
apply_after = hub.timer.apply_after
|
|
@@ -112,6 +114,7 @@ class Pool(bootsteps.StartStopComponent):
|
|
|
w._quick_acquire = w.semaphore.acquire
|
|
|
w._quick_release = w.semaphore.release
|
|
|
max_restarts = 100
|
|
|
+ allow_restart = self.autoreload_enabled or w.pool_restarts
|
|
|
pool = w.pool = self.instantiate(w.pool_cls, w.min_concurrency,
|
|
|
initargs=(w.app, w.hostname),
|
|
|
maxtasksperchild=w.max_tasks_per_child,
|
|
@@ -121,6 +124,7 @@ class Pool(bootsteps.StartStopComponent):
|
|
|
lost_worker_timeout=w.worker_lost_wait,
|
|
|
threads=threaded,
|
|
|
max_restarts=max_restarts,
|
|
|
+ allow_restart=allow_restart,
|
|
|
semaphore=semaphore)
|
|
|
if w.hub:
|
|
|
w.hub.on_init.append(partial(self.on_poll_init, pool))
|