I’m using zeromq and storing per thread copies of zeromq sockets in a
class variable. Same technique used by us and others without any
Here is the code:
s = Offbeat::Zmq::IPCTX.socket(ZMQ::PUSH)
self.clients[Thread.current.object_id] = s
When I call client, and try to send a message on the socket, it just
hangs the app. The guy who created the em-zeromq gem reported the
same problem with zeromq contexts, he had to define the context
outside of the EM.run block when using eventmachine or it would do the
same thing. He thought it was being garbage collected. Fyi I’m
pretty sure he saw this same behavior on Cruby also.
Now, when I just create the socket within the thread, and don’t stick
it in a class variable, it works fine. However I’m using rails so I
really can’t do that, I need somewhere to hold per thread socket
I’m rather stumped on this. Anyone have any ideas?