-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix sys.stdout overriding in mypy.api #6750
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
Conversation
Sadly this is not enough. When For example, I have this simple test program: import mypy.api
stdout, stderr, exitcode = mypy.api.run(['-v', '_.py'])
print('=== stdout ===')
print(stdout)
print('=== stderr ===')
print(stderr)
print('=== exit %d ===' % exitcode) Note that without your patch, the LOG entries are printed under the |
a46c4f3
to
bc4e441
Compare
Overriding sys.stdout and sys.stderr in mypy.api is not threadsafe. This causes problems sometimes when using the api in pyls for example.
bc4e441
to
24f78eb
Compare
PS. While a PR is under review, please don't force-push. This makes the life difficult for the reviewer. We always squash commits when we merge them into master. Is this now ready for another review? |
I realized the issue with it when I read through the contributing guidelines a bit more thoroughly and saw it said to not squash them on my end. I believe it's ready for review. It's possible that I missed something in my fixes or that things were messed up when I rebased to the current master, but I think I got all the code reachable from the api, and the simple test program you provided has the expected output. |
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 think this is much better. Now we just have to figure out a way not to default to the values of sys.stdout/stderr
set at module load time...
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.
Thanks. This looks great! I'll merge this now.
Overriding sys.stdout and sys.stderr in mypy.api is not threadsafe. This causes problems sometimes when using the api in pyls for example. This started with the changes made by @elkhadiy to fix python#6125. Fixes python#6125.
These are the changes made by @elkhadiy to resolve the problems with stdout not being thread-safe in the api.
Fixes #6125.