Server callback on multiple emit() #1129
-
So I have this async server and multiple clients connected. From time to time I need to distribute data over different clients so I multiple-emit to different rooms, one per client. Each client process this data and return its result, which is used by the server to compose the final result. How is the server callback managed in this scenario wrt to "thread" safety? Is there any async-related issue I must consider, e.g. when two or more client replies trigger the execution of this callback on the server at the same time? I guess callback is not guaranteed to be executed atomically out of the box, but I may be wrong. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Callbacks are supported only when addressing a single client. You can emit to your clients one by one in a loop and can bypass this limitation, and then it would be up to your callbacks to figure out which client is responding. You can use |
Beta Was this translation helpful? Give feedback.
Callbacks are supported only when addressing a single client. You can emit to your clients one by one in a loop and can bypass this limitation, and then it would be up to your callbacks to figure out which client is responding. You can use
functools.partial()
to bind each callback to the client it belongs to, for example.