-
Notifications
You must be signed in to change notification settings - Fork 209
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
MOTOR-1087 motor_asyncio freezes when using multiprocessing #196
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
motor/frameworks/asyncio/__init__.py
Outdated
if hasattr(os, "register_at_fork"): | ||
# This will run in the same thread as the fork was called. | ||
# If we fork in a critical region on the same thread, it should break. | ||
# This is fine since we would never call fork directly from a critical region. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this comment trying to say?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this over from Ben's PR, which had this comment for all of the register_at_fork calls. I can remove if you think it is not valuable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't think its valuable. The problem is that it's only describing what after_in_child does. If there was a comment here it should explain why we call it, eg "ThreadPoolExecutor is not fork safe, reinitialize it post fork."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed now.
child_exec = parent_conn.recv() | ||
self.assertIsNot(child_exec, init_exec) | ||
passed, msg = parent_conn.recv() | ||
self.assertTrue(passed, msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of testing that the id of asyncio._EXECUTOR changes, we should test that a new motor client can actually be used in the child process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
motor/frameworks/asyncio/__init__.py
Outdated
|
||
|
||
if hasattr(os, "register_at_fork"): | ||
# We need this to make sure that creating new clients in threads doesn't deadlock. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
threads -> subprocesses
(cherry picked from commit 935c543)
No description provided.