Starts the event loop thread. Parameters: timeout: The maximum amount of time (in seconds) to wait for the event loop to start. Raises: RuntimeError: If called more than once on the same thread value.
(self, *, timeout: Optional[float] = None)
| 92 | self.loop.close() |
| 93 | |
| 94 | def start(self, *, timeout: Optional[float] = None): |
| 95 | """Starts the event loop thread. |
| 96 | |
| 97 | Parameters: |
| 98 | timeout: The maximum amount of time (in seconds) to wait for |
| 99 | the event loop to start. |
| 100 | |
| 101 | Raises: |
| 102 | RuntimeError: If called more than once on the same thread |
| 103 | value. |
| 104 | """ |
| 105 | super().start() |
| 106 | |
| 107 | ready = threading.Event() |
| 108 | self.loop.call_soon_threadsafe(ready.set) |
| 109 | if not ready.wait(timeout=timeout): |
| 110 | raise RuntimeError("Event loop failed to start.") |
| 111 | self.logger.info("Event loop is running.") |
| 112 | |
| 113 | def stop(self): |
| 114 | if self.loop.is_running(): |