Skip to content

How to handle closing sockets? #31

Description

@jnicklas

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:

  1. Simply update the documentation. Leave it up to the user to make sure they call socket.close in a finalizer.

  2. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions