fwcd / fwcd/phare

Use a queue per request id to handle responses

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Currently, a dict is used to share responses from the receive loop with other tasks and a queue of `Event`s that is drained every time a response is received:

https://github.com/fwcd/phare/blob/8dfc62e7a17c10d30c5d0a492e3729157c730c20/phare/lighthouse.py#L22-L35

> [!NOTE]
> 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]]`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.