Spaces:
Running
Running
Create app/broker.py
Browse files- app/broker.py +1 -4
app/broker.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
"""
|
2 |
A singleton message broker for the application.
|
3 |
-
|
4 |
This ensures that the same asyncio.Queue instance is shared across all parts
|
5 |
-
of the application, including background tasks and API request handlers
|
6 |
-
solving state-sharing issues in ASGI lifecycles.
|
7 |
"""
|
8 |
import asyncio
|
9 |
|
@@ -12,5 +10,4 @@ class SignalBroker:
|
|
12 |
self.queue = asyncio.Queue()
|
13 |
|
14 |
# Create a single, global instance of the broker.
|
15 |
-
# When any file imports 'signal_broker', they will get this exact same object.
|
16 |
signal_broker = SignalBroker()
|
|
|
1 |
"""
|
2 |
A singleton message broker for the application.
|
|
|
3 |
This ensures that the same asyncio.Queue instance is shared across all parts
|
4 |
+
of the application, including background tasks and API request handlers.
|
|
|
5 |
"""
|
6 |
import asyncio
|
7 |
|
|
|
10 |
self.queue = asyncio.Queue()
|
11 |
|
12 |
# Create a single, global instance of the broker.
|
|
|
13 |
signal_broker = SignalBroker()
|