Skip to content

Commit 6496455

Browse files
committed
fix(testing): resolve gc shutdown test tracebacks and workflow typos
1 parent 2396607 commit 6496455

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

.github/workflows/praisonai-pr-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ jobs:
6565
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
6666
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
6767
run: |
68-
praisonai agents --file .github/praisonai-reviewer.yaml
68+
praisonai workflow run .github/praisonai-reviewer.yaml

examples/yaml/praisonai-pr-review.yml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ jobs:
6565
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
6666
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
6767
run: |
68-
praisonai agents --file .github/praisonai-reviewer.yaml
68+
praisonai workflow run .github/praisonai-reviewer.yaml

src/praisonai-agents/praisonaiagents/agent/agent.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4547,8 +4547,11 @@ async def aclose(self) -> None:
45474547

45484548
def _cleanup_server_registrations(self) -> None:
45494549
"""Clean up global server registry entries for this agent."""
4550+
if getattr(self, '_agent_id', None) is None:
4551+
return # No ID generated, nothing registered
4552+
45504553
try:
4551-
agent_id = self.agent_id
4554+
agent_id = self._agent_id
45524555
with _server_lock:
45534556
# Remove from _registered_agents
45544557
ports_to_clean = []
@@ -4572,7 +4575,12 @@ def _cleanup_server_registrations(self) -> None:
45724575
# Note: We don't clean up _shared_apps here as other agents might be using them
45734576

45744577
except Exception as e:
4575-
logger.warning(f"Error cleaning up server registrations: {e}")
4578+
import sys
4579+
if sys.meta_path is not None:
4580+
try:
4581+
logger.warning(f"Error cleaning up server registrations: {e}")
4582+
except Exception:
4583+
pass
45764584

45774585
def __enter__(self):
45784586
"""Context manager entry."""
@@ -4591,14 +4599,9 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
45914599
await self.aclose()
45924600

45934601
def __del__(self):
4594-
"""Destructor - ensure resources are cleaned up."""
4595-
try:
4596-
if not getattr(self, '_closed', False):
4597-
self.close()
4598-
except Exception:
4599-
# Ignore errors in destructor to avoid issues during shutdown
4600-
pass
4601-
4602+
"""Destructor safely does nothing to avoid GC pollution in test loops."""
4603+
pass
4604+
46024605
@property
46034606
def is_closed(self) -> bool:
46044607
"""Returns True if the agent has been closed."""

0 commit comments

Comments
 (0)