(stop_event: threading.Event)
| 8 | |
| 9 | def start_proxy_server(port: int = 3002) -> typing.Callable[[], None]: |
| 10 | def run_proxy_server(stop_event: threading.Event) -> None: |
| 11 | server = pproxy.Server(f'http://0.0.0.0:{port}') |
| 12 | args = {'rserver': [], 'verbose': print} |
| 13 | |
| 14 | loop = asyncio.new_event_loop() |
| 15 | asyncio.set_event_loop(loop) |
| 16 | handler = loop.run_until_complete(server.start_server(args)) |
| 17 | |
| 18 | try: |
| 19 | while not stop_event.is_set(): |
| 20 | loop.run_until_complete(asyncio.sleep(0.1)) |
| 21 | except KeyboardInterrupt: |
| 22 | print('exit!') |
| 23 | |
| 24 | handler.close() |
| 25 | loop.run_until_complete(handler.wait_closed()) |
| 26 | loop.run_until_complete(loop.shutdown_asyncgens()) |
| 27 | loop.close() |
| 28 | |
| 29 | # Event to signal the proxy server to stop |
| 30 | stop_event = threading.Event() |
nothing calls this directly
no test coverage detected
searching dependent graphs…