ZMQ.jl icon indicating copy to clipboard operation
ZMQ.jl copied to clipboard

Missing Poller?

Open zsunberg opened this issue 11 years ago • 8 comments

Hi, I'm writing a distributed engineering app with ZMQ. Some of my components will need to read from multiple sockets. I gather from the ZMQ documentation that I will need to use a Poller for this, however I do not see this in the Julia ZMQ implementation.

I see the POLLIN and POLLOUT constants are defined, but I don't see anything else. Is this a missing feature?

zsunberg avatar Apr 09 '14 23:04 zsunberg

I believe on the Julia side you should be able to just use multiple Julia tasks, one for each socket. Does that not work for your usecase?

Keno avatar Apr 09 '14 23:04 Keno

Thanks for the tip. That may work - I need to read up some more on Julia multiprocessing.

zsunberg avatar Apr 10 '14 22:04 zsunberg

This is how IJulia works, since it also needs to read from multiple sockets.

stevengj avatar Apr 11 '14 10:04 stevengj

poll still seems to be missing. I looked into the source but got as far as Base._FDWatcher and thought this was too internal to start playing with.

pearcemc avatar Jan 31 '17 01:01 pearcemc

While it's true that Julia tasks can largely accomplish the tasks that ZMQ polling are useful for, I don't see why we still couldn't a polling API like http://learning-0mq-with-pyzmq.readthedocs.io/en/latest/pyzmq/multisocket/zmqpoller.html.

malmaud avatar Feb 28 '17 14:02 malmaud

@aviks ; we briefly talked at Juliacon about this. The asyncronous majordomo pattern is touted as a very robust solution. For stepwise building and testing of a system, it is very helpful to open an independent REPL for each of the main workers. I have tried looking at implementations in Javascript and Python. But linking the additional c-functions in a good way is a huge and scary step for some of us.

hustf avatar Jun 24 '17 21:06 hustf

As keno and stevengj mentioned above, this pattern is not recommended in Julia. Like nodejs, the simple pattern already "just works" (via Tasks) and doesn't need an additional mechanism to make it parallel (e.g. compare the simplicity of http://zguide.zeromq.org/js:mspoller vs the more complex implementation in python using poller http://zguide.zeromq.org/py:mspoller).

vtjnash avatar Jun 25 '17 00:06 vtjnash

I don't think that enables us to open new processes "by ourselves", e.g. on another computer, and then connect. Which is nice for control freaks or for understanding.

I was not aware of all the functionality in the ClusterManager. There's already a 'broker' implementation extending on zmq.jl so the smart approach is surely to learn to use that.

Ideally, it might perhaps be moved to this package, though. From ZMQCM.jl:

    xpub=Socket(ctx, XPUB)
    xsub=Socket(ctx, XSUB)

    ZMQ.bind(xsub, "tcp://127.0.0.1:$(BROKER_SUB_PORT)")
    ZMQ.bind(xpub, "tcp://127.0.0.1:$(BROKER_PUB_PORT)")

    ccall((:zmq_proxy, :libzmq), Cint,  (Ptr{Void}, Ptr{Void}, Ptr{Void}), xsub.data, xpub.data, C_NULL)

hustf avatar Jun 25 '17 03:06 hustf