-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
PYTHON-4147: Silence noisy thread.start() RuntimeError at shutdown #1486
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.
One clarification for my own understanding, otherwise good!
pymongo/periodic_executor.py
Outdated
try: | ||
thread.start() | ||
except RuntimeError as e: | ||
if str(e) == "can't create new thread at interpreter shutdown": |
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.
We're assuming this error message will remain constant, right?
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.
Yep. Worst case, we can also directly tie this check to version 3.12 if it becomes something that does change. Waiting on response to python/cpython#114570 and follow up based on that.
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.
RuntimeError fix: Check for explicit runtime error message
Could you update the PR title to explain the higher level of what's being changed? Something like "Silence noisy thread.start() RuntimeError at shutdown" would be more enlightening. Also we should add this to the changelog.
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.
Is it possible to add a test for this?
on process shutdown.""" | ||
command = ["python", "-c", "'from pymongo import MongoClient; c = MongoClient()'"] | ||
completed_process: subprocess.CompletedProcess = subprocess.run( | ||
" ".join(command), shell=True, capture_output=True |
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.
No need to join
on command since run() accepts a list.
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.
It needs to be a string with shell=True
specified. I've been attempting to capture the output, and shell=True
has been the main way for me to capture that output. It seems to not capture all of the shell output when done without the shell=True
.
I'm not sure why this is the case and haven't found much good material explaining why, but since these tests are scoped and explicitly defined, I'd argue it's fine to keep this way. The only difference I know is that shell=True
uses whatever native sh
the underlying system uses, environment variables and all.
If anyone does know why it's not capturing the output in either stderr/stdout when using shell=False
that would be great.
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.
Oh I see. Thanks for explaining.
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.
One last thing is to update the changelog to describe this bugfix.
Whoops, lint is failing:
|
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
…ongodb#1486) (cherry picked from commit 0f7e1b0)
No description provided.