| 635 | return self._register(ov, pipe, finish_accept_pipe) |
| 636 | |
| 637 | async def connect_pipe(self, address): |
| 638 | delay = CONNECT_PIPE_INIT_DELAY |
| 639 | while True: |
| 640 | # Unfortunately there is no way to do an overlapped connect to |
| 641 | # a pipe. Call CreateFile() in a loop until it doesn't fail with |
| 642 | # ERROR_PIPE_BUSY. |
| 643 | try: |
| 644 | handle = _overlapped.ConnectPipe(address) |
| 645 | break |
| 646 | except OSError as exc: |
| 647 | if exc.winerror != _overlapped.ERROR_PIPE_BUSY: |
| 648 | raise |
| 649 | |
| 650 | # ConnectPipe() failed with ERROR_PIPE_BUSY: retry later |
| 651 | delay = min(delay * 2, CONNECT_PIPE_MAX_DELAY) |
| 652 | await tasks.sleep(delay) |
| 653 | |
| 654 | return windows_utils.PipeHandle(handle) |
| 655 | |
| 656 | def wait_for_handle(self, handle, timeout=None): |
| 657 | """Wait for a handle. |