CryptoSentinel_AI / app /broker.py
mgbam's picture
Create app/broker.py
e5df665 verified
raw
history blame
513 Bytes
"""
A singleton message broker for the application.
This ensures that the same asyncio.Queue instance is shared across all parts
of the application, including background tasks and API request handlers,
solving state-sharing issues in ASGI lifecycles.
"""
import asyncio
class SignalBroker:
def __init__(self):
self.queue = asyncio.Queue()
# Create a single, global instance of the broker.
# When any file imports 'signal_broker', they will get this exact same object.
signal_broker = SignalBroker()