| 682 | sock, protocol, waiter, extra) |
| 683 | |
| 684 | def close(self): |
| 685 | if self.is_running(): |
| 686 | raise RuntimeError("Cannot close a running event loop") |
| 687 | if self.is_closed(): |
| 688 | return |
| 689 | |
| 690 | if threading.current_thread() is threading.main_thread(): |
| 691 | signal.set_wakeup_fd(-1) |
| 692 | # Call these methods before closing the event loop (before calling |
| 693 | # BaseEventLoop.close), because they can schedule callbacks with |
| 694 | # call_soon(), which is forbidden when the event loop is closed. |
| 695 | self._stop_accept_futures() |
| 696 | self._close_self_pipe() |
| 697 | self._proactor.close() |
| 698 | self._proactor = None |
| 699 | self._selector = None |
| 700 | |
| 701 | # Close the event loop |
| 702 | super().close() |
| 703 | |
| 704 | async def sock_recv(self, sock, n): |
| 705 | return await self._proactor.recv(sock, n) |