(config)
| 332 | |
| 333 | |
| 334 | async def _run(config): |
| 335 | loop = asyncio.get_running_loop() |
| 336 | _log = logging.getLogger("asyncio") |
| 337 | loop.set_exception_handler(_make_exception_handler(_log)) |
| 338 | server = ProxyServer(config) |
| 339 | try: |
| 340 | await server.start() |
| 341 | finally: |
| 342 | await server.stop() |
| 343 | # Cancel any tasks that leaked through (e.g. fire-and-forget pool tasks). |
| 344 | stray = [t for t in asyncio.all_tasks() if t is not asyncio.current_task()] |
| 345 | for t in stray: |
| 346 | t.cancel() |
| 347 | if stray: |
| 348 | await asyncio.gather(*stray, return_exceptions=True) |
| 349 | |
| 350 | |
| 351 | if __name__ == "__main__": |
no test coverage detected