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
Currently, a dict is used to share responses from the receive loop with other tasks and a queue of Events that is drained every time a response is received:
Since we use async/await we don't have to worry about threading issues, since the asyncio runtime is single-threaded. In fact, most asyncio primitives (e.g. Queue or Event) are not thread-safe either.
The disadvantage with this approach is that we only store a single (the most recent) message per request id. For some use cases (e.g. streaming the model itself) this may be fine, but for others it's not (e.g. input events). We should therefore make sure that no responses get discarded. One way to achieve this would be to replace the dict[int, ServerMessage] with a dict[int, Queue[ServerMessage]].
Currently, a dict is used to share responses from the receive loop with other tasks and a queue of
Events that is drained every time a response is received:phare/phare/lighthouse.py
Lines 22 to 35 in 8dfc62e
Note
Since we use async/await we don't have to worry about threading issues, since the
asyncioruntime is single-threaded. In fact, mostasyncioprimitives (e.g.QueueorEvent) are not thread-safe either.The disadvantage with this approach is that we only store a single (the most recent) message per request id. For some use cases (e.g. streaming the model itself) this may be fine, but for others it's not (e.g. input events). We should therefore make sure that no responses get discarded. One way to achieve this would be to replace the
dict[int, ServerMessage]with adict[int, Queue[ServerMessage]].