-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
freethreaded support #193
base: main
Are you sure you want to change the base?
freethreaded support #193
Conversation
716e539
to
4dff78e
Compare
10ed989
to
799728a
Compare
Thanks for working on this! If you have specific things you'd like help on, myself or @ngoldbaum may be of use :) |
I think the two remaining problems are the following:
|
I guess for black, you might be able to just put a lock around that? Sadly Pydantic support is on the way, follow pydantic/pydantic#10483 - probably will be ready in ~1 month. |
This does not work. The problem is that another thread is writing something to sys.stdout at the same time the CliRunner is mocking it to capture the output of black. The following code shows the problem with stdout. # /// script
# dependencies = [
# "pytest",
# "pytest-run-parallel"
# ]
# ///
from contextlib import redirect_stdout
from io import StringIO
import time
def test_redirect():
text=StringIO()
with redirect_stdout(text):
print("hello")
time.sleep(1)
print("hello")
assert text.getvalue()=="hello\nhello\n"
if __name__ == "__main__":
import pytest
pytest.main(["--parallel-threads=5",__file__]) contextlib.redirect_stdout is also not thread save for the same reason. It is modifying global state. I don't know if stdin/stdout can be fixed in the same way. |
Maybe open a CPython bug? It seems reasonable to me for python to add locking for global state in the C standard library. |
solves #192