Created
June 16, 2014 08:20
-
-
Save indradhanush/4448fc0d634e50441c69 to your computer and use it in GitHub Desktop.
Reproducing blocking zmq.Context.term() vs Non blocking zmq.Context.destroy()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zmq | |
# Server | |
class Server(): | |
def __init__(self, context): | |
self.context = context | |
self.router = self.context.socket(zmq.ROUTER) | |
self.router.bind("tcp://127.0.0.1:9876") | |
def kill_server(self): | |
self.context.term() | |
# self.context.destroy() | |
# Client | |
class Client(): | |
def __init__(self, context): | |
self.context = context | |
self.speaker = self.context.socket(zmq.DEALER) | |
self.speaker.connect("tcp://127.0.0.1:9876") | |
def kill_client(self): | |
self.context.term() | |
# self.context.destroy() | |
if __name__ == "__main__": | |
server = Server(zmq.Context()) | |
client = Client(zmq.Context()) | |
# This blocks. | |
client.kill_client() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment