Schedule the shutdown of the default executor. The timeout parameter specifies the amount of time the executor will be given to finish joining. The default value is None, which means that the executor will be given an unlimited amount of time.
(self, timeout=None)
| 598 | }) |
| 599 | |
| 600 | async def shutdown_default_executor(self, timeout=None): |
| 601 | """Schedule the shutdown of the default executor. |
| 602 | |
| 603 | The timeout parameter specifies the amount of time the executor will |
| 604 | be given to finish joining. The default value is None, which means |
| 605 | that the executor will be given an unlimited amount of time. |
| 606 | """ |
| 607 | self._executor_shutdown_called = True |
| 608 | if self._default_executor is None: |
| 609 | return |
| 610 | future = self.create_future() |
| 611 | thread = threading.Thread(target=self._do_shutdown, args=(future,)) |
| 612 | thread.start() |
| 613 | try: |
| 614 | async with timeouts.timeout(timeout): |
| 615 | await future |
| 616 | except TimeoutError: |
| 617 | warnings.warn("The executor did not finishing joining " |
| 618 | f"its threads within {timeout} seconds.", |
| 619 | RuntimeWarning, stacklevel=2) |
| 620 | self._default_executor.shutdown(wait=False) |
| 621 | else: |
| 622 | thread.join() |
| 623 | |
| 624 | def _do_shutdown(self, future): |
| 625 | try: |