|
56 | 56 | from simcore_service_webserver.socketio.plugin import setup_socketio |
57 | 57 | from simcore_service_webserver.users.plugin import setup_users |
58 | 58 | from sqlalchemy import func, select |
| 59 | +from tenacity import AsyncRetrying, stop_after_delay, wait_fixed |
59 | 60 |
|
60 | 61 | log = logging.getLogger(__name__) |
61 | 62 |
|
@@ -344,9 +345,16 @@ async def disconnect_user_from_socketio( |
344 | 345 | await sio.disconnect() |
345 | 346 | assert not sio.sid |
346 | 347 | await asyncio.sleep(0) # just to ensure there is a context switch |
347 | | - assert not await socket_registry.find_keys(("socket_id", sio.get_sid())) |
348 | | - assert sid not in await socket_registry.find_resources(resource_key, "socket_id") |
349 | | - assert not await socket_registry.find_resources(resource_key, "socket_id") |
| 348 | + |
| 349 | + async for attempt in AsyncRetrying( |
| 350 | + wait=wait_fixed(0.1), stop=stop_after_delay(5), reraise=True |
| 351 | + ): |
| 352 | + with attempt: |
| 353 | + assert not await socket_registry.find_keys(("socket_id", sio.get_sid())) |
| 354 | + assert sid not in await socket_registry.find_resources( |
| 355 | + resource_key, "socket_id" |
| 356 | + ) |
| 357 | + assert not await socket_registry.find_resources(resource_key, "socket_id") |
350 | 358 |
|
351 | 359 |
|
352 | 360 | async def assert_users_count( |
@@ -477,7 +485,6 @@ async def test_t1_while_guest_is_connected_no_resources_are_removed( |
477 | 485 | await assert_project_in_db(aiopg_engine, empty_guest_user_project) |
478 | 486 |
|
479 | 487 |
|
480 | | -@pytest.mark.flaky(max_runs=3) |
481 | 488 | async def test_t2_cleanup_resources_after_browser_is_closed( |
482 | 489 | disable_garbage_collector_task: None, |
483 | 490 | client: TestClient, |
|
0 commit comments