28
28
)
29
29
30
30
BASE_TIMEOUT = 10
31
- PORT = 17394
31
+ PORT = 5000
32
32
URL = f"http://localhost:{ PORT } "
33
33
34
34
@@ -54,14 +54,14 @@ def run_server():
54
54
@pytest .fixture ()
55
55
async def client_1 () -> socketio .AsyncSimpleClient :
56
56
async with socketio .AsyncSimpleClient () as sio :
57
- await sio .connect (URL , transports = [ "websocket" ] )
57
+ await sio .connect (URL , wait_timeout = BASE_TIMEOUT )
58
58
yield sio
59
59
60
60
61
61
@pytest .fixture ()
62
62
async def client_2 () -> socketio .AsyncSimpleClient :
63
63
async with socketio .AsyncSimpleClient () as sio :
64
- await sio .connect (URL , transports = [ "websocket" ] )
64
+ await sio .connect (URL , wait_timeout = BASE_TIMEOUT )
65
65
yield sio
66
66
67
67
@@ -427,38 +427,39 @@ async def test_runtime_error(
427
427
428
428
# Test shutdown --------------------------------------------------------------------------------------------------------
429
429
430
- SHUTDOWN_PORT = PORT + 1
431
- SHUTDOWN_URL = f"http://localhost:{ SHUTDOWN_PORT } "
432
-
433
-
434
- async def test_shutdown () -> None :
435
- # Start the server that should be shut down
436
- process = multiprocessing .Process (target = run_server_to_shutdown )
437
- process .start ()
438
-
439
- # Send a shutdown message
440
- async with socketio .AsyncSimpleClient () as client_ :
441
- await client_ .connect (SHUTDOWN_URL , transports = ["websocket" ])
442
- await client_ .emit (create_shutdown_message ().event )
443
-
444
- # Joining on the process can lead to a loss of the shutdown message
445
- for _ in range (10 * BASE_TIMEOUT ):
446
- if not process .is_alive ():
447
- break
448
- await asyncio .sleep (0.1 )
449
-
450
- # Kill the process and all child processes if it did not shut down in time
451
- if process .is_alive ():
452
- parent = psutil .Process (process .pid )
453
- for child in parent .children (recursive = True ):
454
- child .kill ()
455
- pytest .fail ("Server did not shut down in time." )
456
-
457
- # Check the exit code
458
- assert process .exitcode == 0
459
-
460
-
461
- def run_server_to_shutdown ():
462
- server = SafeDsServer ()
463
- server ._sio .eio .start_service_task = False
464
- asyncio .run (server .startup (SHUTDOWN_PORT ))
430
+ # SHUTDOWN_PORT = PORT + 1
431
+ # SHUTDOWN_URL = f"http://localhost:{SHUTDOWN_PORT}"
432
+ #
433
+ #
434
+ # async def test_shutdown() -> None:
435
+ # # Start the server that should be shut down
436
+ # process = multiprocessing.Process(target=run_server_to_shutdown)
437
+ # process.start()
438
+ #
439
+ # try:
440
+ # # Send a shutdown message
441
+ # async with socketio.AsyncSimpleClient() as client_:
442
+ # await client_.connect(SHUTDOWN_URL, wait_timeout=BASE_TIMEOUT)
443
+ # await client_.emit(create_shutdown_message().event)
444
+ #
445
+ # # Joining on the process can lead to a loss of the shutdown message
446
+ # for _ in range(10 * BASE_TIMEOUT):
447
+ # if not process.is_alive():
448
+ # break
449
+ # await asyncio.sleep(0.1)
450
+ # finally:
451
+ # # Kill the process and all child processes if it did not shut down in time
452
+ # if process.is_alive():
453
+ # parent = psutil.Process(process.pid)
454
+ # for child in parent.children(recursive=True):
455
+ # child.kill()
456
+ # pytest.fail("Server did not shut down in time.")
457
+ #
458
+ # # Check the exit code
459
+ # assert process.exitcode == 0
460
+ #
461
+ #
462
+ # def run_server_to_shutdown():
463
+ # server = SafeDsServer()
464
+ # server._sio.eio.start_service_task = False
465
+ # asyncio.run(server.startup(SHUTDOWN_PORT))
0 commit comments