Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent race condition when finished working #35

Open
paneq opened this issue Jul 29, 2012 · 2 comments
Open

Prevent race condition when finished working #35

paneq opened this issue Jul 29, 2012 · 2 comments

Comments

@paneq
Copy link
Collaborator

paneq commented Jul 29, 2012

Use ZMQ3 disconnect / unbind API whenever possible to avoid situation like this in Python mongrel2 adapter:

def shutdown(self,timeout=None):
        """Shut down the connection.

        This indicates that no more requests should be received by the
        handler, but it is willing to process any that have already been
        transmitted.  Use it for graceful termination of handlers.

        After shutdown, you may only call recv() with timeout=0.

        For the standard PULL socket, a clean shutdown is not possible
        as zmq has no API for it.  What we do is quickly ready anything
        that's pending for delivery then close the socket.  This leaves
        a slight race condition that a request will be pushed to us and
        then lost.
        """
        msg = self._recv(timeout=0)
        while msg is not None:
            self.recv_buffer.append(msg)
            msg = self._recv(timeout=0)
        self.send_sock.close()
        super(Connection,self).shutdown(timeout)
@paneq
Copy link
Collaborator Author

paneq commented Jul 29, 2012

chuckremes/ffi-rzmq#57

@paneq
Copy link
Collaborator Author

paneq commented Aug 3, 2012

This was fixed in ffi-rzmq and we can start working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant