I'm in the process of writing a few specs for this gem. I ran into a problem which I wanted to get some feedback on. In order to separate tests more cleanly from each other, I wrapped all tests in an around filter which calls Celluloid::ZMQ.init before and Celluloid::ZMQ.terminate afterwards, so it sets up a clean ZMQ context for each test. This seems to work nicely, except that zmq_term hangs indefinitely until all sockets created within the context are explicitly closed. This means that every socket we create, we need to explicitly close.
The way I see it, there are two ways of handling this:
-
Simply update the documentation. Leave it up to the user to make sure they call socket.close in a finalizer.
-
Keep track of all sockets created within an actor and add a finalizer to Celluloid::ZMQ which closes them automatically.
While (2) is more user friendly, it could also be problematic, since Celluloid can only have one finalizer per actor (why, btw?), if the user ever adds their own finalizer to the actor, they would overwrite the built in finalizer and mess up the sockets getting closed. So in a way, I think (1) is the better solution at this point.
What do you think?
I'm in the process of writing a few specs for this gem. I ran into a problem which I wanted to get some feedback on. In order to separate tests more cleanly from each other, I wrapped all tests in an around filter which calls
Celluloid::ZMQ.initbefore andCelluloid::ZMQ.terminateafterwards, so it sets up a clean ZMQ context for each test. This seems to work nicely, except thatzmq_termhangs indefinitely until all sockets created within the context are explicitly closed. This means that every socket we create, we need to explicitly close.The way I see it, there are two ways of handling this:
Simply update the documentation. Leave it up to the user to make sure they call
socket.closein a finalizer.Keep track of all sockets created within an actor and add a finalizer to Celluloid::ZMQ which closes them automatically.
While (2) is more user friendly, it could also be problematic, since Celluloid can only have one finalizer per actor (why, btw?), if the user ever adds their own finalizer to the actor, they would overwrite the built in finalizer and mess up the sockets getting closed. So in a way, I think (1) is the better solution at this point.
What do you think?