GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit e91023d8 authored by Olof Svensson's avatar Olof Svensson

Made pool with no daemon

parent 7153e1e8
......@@ -31,6 +31,7 @@ import traceback
import functools
import importlib
import multiprocessing
import multiprocessing.pool
from pypushflow.AbstractActor import AbstractActor
......@@ -65,12 +66,37 @@ def trace_unhandled_exceptions(func):
return wrapped_func
#############################################################################
# Create no daemon processes
# See : https://stackoverflow.com/a/8963618
#
class NoDaemonProcess(multiprocessing.Process):
# make 'daemon' attribute always return False
def _get_daemon(self):
return False
def _set_daemon(self, value):
pass
daemon = property(_get_daemon, _set_daemon)
# We sub-class multiprocessing.pool.Pool instead of multiprocessing.Pool
# because the latter is only a wrapper function, not a proper class.
class Edna2Pool(multiprocessing.pool.Pool):
Process = NoDaemonProcess
#
#
#############################################################################
class AsyncFactory:
def __init__(self, func, callback=None, errorCallback=None):
self.func = func
self.callback = callback
self.errorCallback = errorCallback
self.pool = multiprocessing.Pool()
self.pool = Edna2Pool()
def call(self, *args, **kwargs):
logger.debug('Before apply_async, func={0}, callback={1}, errorCallback={2}'.format(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment