[zeromq-dev] [pyzmq]: Asynchronous client api design

Yassine Lamgarchal bouceka78 at gmail.com
Mon Mar 9 00:55:57 CET 2015

Hello all o/,

I'm currently designing a distributed application which is composed of
and a remote server.

I struggle with the asynchronous client api... I want it to be the most
to use and to implement.

Here is some background: the clients can send commands, when the server
receive the
command it does some work and response back to the client. For that, i use
socket in the client side and a ROUTER socket in the server side because i
want the
client and the server to be asynchronous. In addition, the client can
receive some
unexpected event messages.

An UUID is associated to each command.

What i want to do, from a user point of view, is something like that:

    - async_result = client.command("some_data") # send the command to the
    - ... do other stufs ...
    - result = async_result.get() # block until the response is available

Here is a schema of what i imagined so far:

In this design, there is a thread which run an event loop, this event loop
will listen
to a PAIR socket which make the client able to interact with it
and tells it to send commands.

When the server send the response, the event loop handler will put the
response on
a data structure with the command UUID. The client can retrieve the
response thanks
to the command UUID.

So there is a synchronization to do between the main application thread and
"framework thread".

My questions are the following:

    1. Do you think its a simple design for this purpose ?
    2. Is it possible to avoid the use of a "framework thread"(and then
avoid threads synchronization) ?

Thank you for your help in advance :) !

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150309/22fd12bb/attachment.htm>

More information about the zeromq-dev mailing list