-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-101881: os: support blocking functions on Windows #101882
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
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
4d9f33d
to
8682166
Compare
8682166
to
a55d600
Compare
Tested with this script: import os
import sys
r, w = os.pipe()
os.set_blocking(r, sys.argv[1] == 'True')
os.set_blocking(w, sys.argv[1] == 'True')
if (os.get_blocking(r) and os.get_blocking(w)):
print("blocking")
else:
print("non-blocking")
try:
while True:
os.write(w, b'hello')
except BlockingIOError:
print("blocked") Output: PS C:\Users\Rayyan\cpython> PCbuild\amd64\python_d.exe ..\test_blocking.py False
non-blocking
blocked
PS C:\Users\Rayyan\cpython> PCbuild\amd64\python_d.exe ..\test_blocking.py True
blocking
[script hangs] |
b34c8a4
to
658e4f2
Compare
0277c03
to
f853e83
Compare
939920f
to
ba175a1
Compare
Should now be ready to merge. |
918bde3
to
462cc40
Compare
Refer to [MS-FSCC]:
It would be nice if the Windows API exposed |
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
1863704
to
b3af6b2
Compare
Handle erroring operations on non-blocking pipes by reading the _doserrno code. Limit writes on non-blocking pipes that are too large.
Use the GetNamedPipeHandleState and SetNamedPipeHandleState Win32 API functions to add support for os.get_blocking and os.set_blocking.
b3af6b2
to
3626c05
Compare
I have made the requested changes; please review again. |
Thanks for making the requested changes! @zooba: please review the changes made to this pull request. |
Thanks for the contribution! Just FYI, there's no need to force push updates to PRs for our project - we always squash merge and edit the commit messages ourselves. All that a force push will do is reset the review status, which makes it hard to see the most recent changes. |
Use the GetNamedPipeHandleState and SetNamedPipeHandleState Win32 API functions to add support for os.get_blocking and os.set_blocking.