OLD | NEW |
1 """Event loop using a proactor and related classes. | 1 """Event loop using a proactor and related classes. |
2 | 2 |
3 A proactor is a "notify-on-completion" multiplexer. Currently a | 3 A proactor is a "notify-on-completion" multiplexer. Currently a |
4 proactor is only implemented on Windows with IOCP. | 4 proactor is only implemented on Windows with IOCP. |
5 """ | 5 """ |
6 | 6 |
7 __all__ = ['BaseProactorEventLoop'] | 7 __all__ = ['BaseProactorEventLoop'] |
8 | 8 |
9 import socket | 9 import socket |
10 import sys | 10 import sys |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 self.call_exception_handler({ | 482 self.call_exception_handler({ |
483 'message': 'Error on reading from the event loop self pipe', | 483 'message': 'Error on reading from the event loop self pipe', |
484 'exception': exc, | 484 'exception': exc, |
485 'loop': self, | 485 'loop': self, |
486 }) | 486 }) |
487 else: | 487 else: |
488 self._self_reading_future = f | 488 self._self_reading_future = f |
489 f.add_done_callback(self._loop_self_reading) | 489 f.add_done_callback(self._loop_self_reading) |
490 | 490 |
491 def _write_to_self(self): | 491 def _write_to_self(self): |
| 492 # The self-pipe must not be shared between two processes: at fork, |
| 493 # create a new pipe to unshare it |
| 494 self._detect_fork() |
| 495 |
492 self._csock.send(b'\0') | 496 self._csock.send(b'\0') |
493 | 497 |
494 def _start_serving(self, protocol_factory, sock, | 498 def _start_serving(self, protocol_factory, sock, |
495 sslcontext=None, server=None): | 499 sslcontext=None, server=None): |
496 | 500 |
497 def loop(f=None): | 501 def loop(f=None): |
498 try: | 502 try: |
499 if f is not None: | 503 if f is not None: |
500 conn, addr = f.result() | 504 conn, addr = f.result() |
501 if self._debug: | 505 if self._debug: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 | 542 |
539 def _stop_accept_futures(self): | 543 def _stop_accept_futures(self): |
540 for future in self._accept_futures.values(): | 544 for future in self._accept_futures.values(): |
541 future.cancel() | 545 future.cancel() |
542 self._accept_futures.clear() | 546 self._accept_futures.clear() |
543 | 547 |
544 def _stop_serving(self, sock): | 548 def _stop_serving(self, sock): |
545 self._stop_accept_futures() | 549 self._stop_accept_futures() |
546 self._proactor._stop_serving(sock) | 550 self._proactor._stop_serving(sock) |
547 sock.close() | 551 sock.close() |
OLD | NEW |