mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(test): add event loop cleanup to prevent CI test failures
Adds a 0.5s sleep after shutting down test services (ExecutionManager, AgentServer, etc.) to ensure they fully clean up their event loops before the next test starts. This prevents 'Event loop is closed' errors in CI that were breaking the oauth_test.py fixture setup. The issue occurred because: 1. SpinTestServer starts background services with their own event loops 2. When services shut down, event loops weren't fully cleaned up 3. Subsequent tests would encounter closed event loops Fixes test isolation issue where review_routes_test.py would leave the event loop in a bad state for tests running after it.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import inspect
|
||||
import logging
|
||||
import time
|
||||
@@ -58,6 +59,11 @@ class SpinTestServer:
|
||||
self.db_api.__exit__(exc_type, exc_val, exc_tb)
|
||||
self.notif_manager.__exit__(exc_type, exc_val, exc_tb)
|
||||
|
||||
# Give services time to fully shut down
|
||||
# This prevents event loop issues where services haven't fully cleaned up
|
||||
# before the next test starts
|
||||
await asyncio.sleep(0.5)
|
||||
|
||||
def setup_dependency_overrides(self):
|
||||
# Override get_user_id for testing
|
||||
self.agent_server.set_test_dependency_overrides(
|
||||
|
||||
Reference in New Issue
Block a user