|
@@ -14,6 +14,7 @@
|
|
from __future__ import absolute_import
|
|
from __future__ import absolute_import
|
|
from __future__ import with_statement
|
|
from __future__ import with_statement
|
|
|
|
|
|
|
|
+import os
|
|
import threading
|
|
import threading
|
|
|
|
|
|
from functools import partial
|
|
from functools import partial
|
|
@@ -29,6 +30,8 @@ from .hub import DummyLock
|
|
logger = get_logger(__name__)
|
|
logger = get_logger(__name__)
|
|
debug, info, error = logger.debug, logger.info, logger.error
|
|
debug, info, error = logger.debug, logger.info, logger.error
|
|
|
|
|
|
|
|
+AUTOSCALE_KEEPALIVE = int(os.environ.get('AUTOSCALE_KEEPALIVE', 30))
|
|
|
|
+
|
|
|
|
|
|
class WorkerComponent(StartStopComponent):
|
|
class WorkerComponent(StartStopComponent):
|
|
name = 'worker.autoscaler'
|
|
name = 'worker.autoscaler'
|
|
@@ -65,7 +68,7 @@ class WorkerComponent(StartStopComponent):
|
|
class Autoscaler(bgThread):
|
|
class Autoscaler(bgThread):
|
|
|
|
|
|
def __init__(self, pool, max_concurrency,
|
|
def __init__(self, pool, max_concurrency,
|
|
- min_concurrency=0, keepalive=30, mutex=None):
|
|
|
|
|
|
+ min_concurrency=0, keepalive=AUTOSCALE_KEEPALIVE, mutex=None):
|
|
super(Autoscaler, self).__init__()
|
|
super(Autoscaler, self).__init__()
|
|
self.pool = pool
|
|
self.pool = pool
|
|
self.mutex = mutex or threading.Lock()
|
|
self.mutex = mutex or threading.Lock()
|