Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
workflow
pypushflow
Commits
e91023d8
Commit
e91023d8
authored
Oct 01, 2019
by
Olof Svensson
Browse files
Made pool with no daemon
parent
7153e1e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
pypushflow/PythonActor.py
View file @
e91023d8
...
...
@@ -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
=
Edna2
Pool
()
def
call
(
self
,
*
args
,
**
kwargs
):
logger
.
debug
(
'Before apply_async, func={0}, callback={1}, errorCallback={2}'
.
format
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment