| 789 | self._internal_fds += 1 |
| 790 | |
| 791 | def _loop_self_reading(self, f=None): |
| 792 | try: |
| 793 | if f is not None: |
| 794 | f.result() # may raise |
| 795 | if self._self_reading_future is not f: |
| 796 | # When we scheduled this Future, we assigned it to |
| 797 | # _self_reading_future. If it's not there now, something has |
| 798 | # tried to cancel the loop while this callback was still in the |
| 799 | # queue (see windows_events.ProactorEventLoop.run_forever). In |
| 800 | # that case stop here instead of continuing to schedule a new |
| 801 | # iteration. |
| 802 | return |
| 803 | f = self._proactor.recv(self._ssock, 4096) |
| 804 | except exceptions.CancelledError: |
| 805 | # _close_self_pipe() has been called, stop waiting for data |
| 806 | return |
| 807 | except (SystemExit, KeyboardInterrupt): |
| 808 | raise |
| 809 | except BaseException as exc: |
| 810 | self.call_exception_handler({ |
| 811 | 'message': 'Error on reading from the event loop self pipe', |
| 812 | 'exception': exc, |
| 813 | 'loop': self, |
| 814 | }) |
| 815 | else: |
| 816 | self._self_reading_future = f |
| 817 | f.add_done_callback(self._loop_self_reading) |
| 818 | |
| 819 | def _write_to_self(self): |
| 820 | # This may be called from a different thread, possibly after |