diff --git a/contrib/procpools/python_procpool.py b/contrib/procpools/python_procpool.py index da2bc35c6e..11c46b9d75 100644 --- a/contrib/procpools/python_procpool.py +++ b/contrib/procpools/python_procpool.py @@ -111,10 +111,8 @@ class PythonProcPoolChild(AMPChild): try: environment = from_pickle(environment) available_vars.update(environment) - except Exception, e: + except Exception: logger.log_trace() - _return(e) - # try to execute with eval first try: ret = eval(source, {}, available_vars) @@ -132,12 +130,14 @@ class PythonProcPoolChild(AMPChild): to_recache = to_pickle(objs, emptypickle=False) or "" # empty the list without loosing memory reference PROC_MODIFIED_OBJS[:] = [] - print "... executecode done." return {'response': ret, 'recached': to_recache} ExecuteCode.responder(executecode) +# +# Procpool run_async - Server-side access function for executing code in another process +# _PPOOL = None _SESSIONS = None @@ -231,7 +231,7 @@ def run_async(to_execute, *args, **kwargs): except AttributeError: _PPOOL = False - use_timeout = kwargs.pop("proc_timeout", None) + use_timeout = kwargs.pop("proc_timeout", _PPOOL.timeout) # helper converters for callbacks/errbacks def convert_return(f): diff --git a/contrib/procpools/python_procpool_plugin.py b/contrib/procpools/python_procpool_plugin.py index 4bb8de7b21..c05180b22b 100644 --- a/contrib/procpools/python_procpool_plugin.py +++ b/contrib/procpools/python_procpool_plugin.py @@ -30,12 +30,13 @@ PROCPOOL_DEBUG = True PROCPOOL_MIN_NPROC = 5 PROCPOOL_MAX_NPROC = 20 # after sending a command, this is the maximum time in seconds the process -# may run without returning. After this time the process will be killed -PROCPOOL_TIMEOUT = 15 +# may run without returning. After this time the process will be killed. This +# can be seen as a fallback; the run_async method takes a keyword proc_timeout +# that will override this value on a per-case basis. +PROCPOOL_TIMEOUT = 10 # maximum time (seconds) a process may idle before being pruned from pool (if pool bigger than minsize) PROCPOOL_IDLETIME = 20 # only change if the port clashes with something else on the system -PROCPOOL_HOST = 'localhost' PROCPOOL_PORT = 5001 # 0.0.0.0 means listening to all interfaces PROCPOOL_INTERFACE = '0.0.0.0' @@ -96,6 +97,7 @@ def start_plugin_services(server): max=PROCPOOL_MAX_NPROC, recycleAfter=500, timeout=PROCPOOL_TIMEOUT, + maxIdle=PROCPOOL_IDLETIME, ampChild=PythonProcPoolChild, starter=procpool_starter) procpool_service = ampoule_service.AMPouleService(procpool, diff --git a/contrib/procpools/python_run_async.py b/contrib/procpools/python_run_async.py deleted file mode 100644 index 00839ba189..0000000000 --- a/contrib/procpools/python_run_async.py +++ /dev/null @@ -1,5 +0,0 @@ - -# -# Python Async runner - server-side AMP access function -# -