Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks including CrewAI, Agno, OpenAI Agents SDK, Langchain, Autogen, AG2, and CamelAI
Python agentagentopsagents-sdkaianthropicautogencost-estimationcrewaievalsevaluation-metricsgroqlangchainllmmistralollamaopenaiopenai-agents
only watch signal if main thread (#152)
Braelyn Boyntona1c998da72da
diff --git a/agentops/client.py b/agentops/client.pyindex 339a2013..69998765 100644--- a/agentops/client.py+++ b/agentops/client.py@@ -19,6 +19,7 @@ import inspectimport atexitimport signalimport sys+import threadingfrom .meta_client import MetaClientfrom .config import Configuration, ConfigurationError@@ -293,11 +294,13 @@ class Client(metaclass=MetaClient):# Then call the default excepthook to exit the programsys.__excepthook__(exc_type, exc_value, exc_traceback)- atexit.register(lambda: cleanup(end_state="Indeterminate",- end_state_reason="Process exited without calling end_session()"))- signal.signal(signal.SIGINT, signal_handler)- signal.signal(signal.SIGTERM, signal_handler)- sys.excepthook = handle_exception+ # if main thread+ if isinstance(threading.current_thread(), threading._MainThread):+ atexit.register(lambda: cleanup(end_state="Indeterminate",+ end_state_reason="Process exited without calling end_session()"))+ signal.signal(signal.SIGINT, signal_handler)+ signal.signal(signal.SIGTERM, signal_handler)+ sys.excepthook = handle_exception@propertydef current_session_id(self):