You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Closes the queue for future push events and also closes all child queues.
137
+
138
+
Once closed, no new events can be enqueued. For Python 3.13+, this will trigger
139
+
`asyncio.QueueShutDown` when the queue is empty and a consumer tries to dequeue.
140
+
For lower versions, the queue will be marked as closed and optionally cleared.
141
+
142
+
Args:
143
+
immediate (bool):
144
+
- True: Immediately closes the queue and clears all unprocessed events without waiting for them to be consumed. This is suitable for scenarios where you need to forcefully interrupt and quickly release resources.
145
+
- False (default): Gracefully closes the queue, waiting for all queued events to be processed (i.e., the queue is drained) before closing. This is suitable when you want to ensure all events are handled.
137
146
138
-
Once closed, `dequeue_event` will eventually raise `asyncio.QueueShutDown`
139
-
when the queue is empty. Also closes all child queues.
140
147
"""
141
148
logger.debug('Closing EventQueue.')
142
149
asyncwithself._lock:
143
150
# If already closed, just return.
144
-
ifself._is_closed:
151
+
ifself._is_closedandnotimmediate:
145
152
return
146
-
self._is_closed=True
153
+
ifnotself._is_closed:
154
+
self._is_closed=True
147
155
# If using python 3.13 or higher, use the shutdown method
0 commit comments