| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -10,7 +10,6 @@ | |
| import msvcrt | ||
| import os | ||
| import subprocess | ||
| import tempfile | ||
| import warnings | ||
|
|
||
|
|
||
| Expand All | @@ -24,17 +23,14 @@ | |
| PIPE = subprocess.PIPE | ||
| STDOUT = subprocess.STDOUT | ||
| _mmap_counter = itertools.count() | ||
| _MAX_PIPE_ATTEMPTS = 20 | ||
|
|
||
|
|
||
| # Replacement for os.pipe() using handles instead of fds | ||
|
|
||
|
|
||
| def pipe(*, duplex=False, overlapped=(True, True), bufsize=BUFSIZE): | ||
| """Like os.pipe() but with overlapped support and using handles not fds.""" | ||
| address = tempfile.mktemp( | ||
| prefix=r'\\.\pipe\python-pipe-{:d}-{:d}-'.format( | ||
| os.getpid(), next(_mmap_counter))) | ||
|
|
||
| if duplex: | ||
| openmode = _winapi.PIPE_ACCESS_DUPLEX | ||
| access = _winapi.GENERIC_READ | _winapi.GENERIC_WRITE | ||
| Expand All | @@ -56,9 +52,20 @@ def pipe(*, duplex=False, overlapped=(True, True), bufsize=BUFSIZE): | |
|
|
||
| h1 = h2 = None | ||
| try: | ||
| h1 = _winapi.CreateNamedPipe( | ||
| address, openmode, _winapi.PIPE_WAIT, | ||
| 1, obsize, ibsize, _winapi.NMPWAIT_WAIT_FOREVER, _winapi.NULL) | ||
| for attempts in itertools.count(): | ||
| address = r'\\.\pipe\python-pipe-{:d}-{:d}-{}'.format( | ||
| os.getpid(), next(_mmap_counter), os.urandom(8).hex()) | ||
| try: | ||
| h1 = _winapi.CreateNamedPipe( | ||
| address, openmode, _winapi.PIPE_WAIT, | ||
| 1, obsize, ibsize, _winapi.NMPWAIT_WAIT_FOREVER, _winapi.NULL) | ||
| break | ||
| except OSError as e: | ||
| if attempts >= _MAX_PIPE_ATTEMPTS: | ||
| raise | ||
| if e.winerror not in (_winapi.ERROR_PIPE_BUSY, | ||
| _winapi.ERROR_ACCESS_DENIED): | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityan infinite loop retrying on this error could potentially hide an error if the system simply doesn't allow this process to create a pipe with the given address? (here and below)
Sorry, something went wrong.
serhiy-storchaka reacted with thumbs up emoji
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI do not know if this is even possible (\\.\pipe\ is not a real directory which you can forbid access to), but it will not harm if limit the number of attempts.
Sorry, something went wrong.
All reactions
|
||
| raise | ||
|
|
||
| h2 = _winapi.CreateFile( | ||
| address, access, 0, _winapi.NULL, _winapi.OPEN_EXISTING, | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Get rid of any possibility of a name conflict for named pipes in | ||
| :mod:`multiprocessing` and :mod:`asyncio` on Windows, no matter how small. |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.