-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manager().Pool gets stuck with billiard, works with multiprocessing #340
Comments
it seems like the issue with passing lock to the child process def child_proc_simple(task_id):
#time.sleep(1)
print(task_id)
def child_proc_simple_with_lock(lock, task_id):
#time.sleep(1)
print(task_id)
def simple():
with mproc.Manager() as manager:
# create a variable shared across all threads
shared_best_result = manager.dict()
best_results_schema = {
'task_id': None,
'time': None,
'best': np.inf,
}
for k,v in best_results_schema.items():
shared_best_result[k] = v
lock = manager.Lock()
with manager.Pool(processes=5) as pool:
# this works: <------- WORKS
result = pool.starmap(child_proc_simple, [(
lock,
task_id,
) for task_id in range(10)])
# this does not work, gets stuck <------- FAILS
result = pool.starmap(child_proc_simple_with_lock, [(
lock,
task_id,
) for task_id in range(10)])
logger.info(shared_best_result)
# convert Manager.dict to python's dict before exiting Manager context
result = dict(shared_best_result)
return result |
Using processes directly seems to work.
this is a workaround, closing this for now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Functional example below works with
multiprocessing
but fails (gets stuck at pool.starmap) withbilliard
. Is there anything wrong with this example, does it need to be adapted to billiard somehow?billiard==3.6.4.0
python3.9.0
MacOS Catalina
Thanks for help!!
The text was updated successfully, but these errors were encountered: