Created
August 6, 2012 18:59
-
-
Save bombela/3277557 to your computer and use it in GitHub Desktop.
stress PyZMQ to trigger the 'missing event' problem
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
#!/usr/bin/env python | |
import zerorpc.gevent_zmq as zmq | |
context = zmq.Context() | |
c = zmq.Socket(context, zmq.XREQ) | |
c.connect('tcp://127.0.0.1:9998') | |
print 'running' | |
while True: | |
c.send('', flags=zmq.SNDMORE) | |
c.send('ping') | |
msg = c.recv() | |
assert msg == 'maybe' |
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
#!/usr/bin/env python | |
import zerorpc.gevent_zmq as zmq | |
import gevent | |
context = zmq.Context() | |
c = zmq.Socket(context, zmq.XREQ) | |
c.connect('tcp://127.0.0.1:9999') | |
s = zmq.Socket(context, zmq.XREP) | |
s.bind('tcp://127.0.0.1:9998') | |
def task(zmqid, msg): | |
c.send('', flags=zmq.SNDMORE) | |
c.send('ping') | |
msg = c.recv() | |
s.send(zmqid, flags=zmq.SNDMORE) | |
s.send(msg) | |
print 'running' | |
while True: | |
zmqid = s.recv() | |
s.recv() | |
msg = s.recv() | |
gevent.spawn(task, zmqid, msg) |
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
#!/usr/bin/env python | |
import zerorpc.gevent_zmq as zmq | |
context = zmq.Context() | |
s = zmq.Socket(context, zmq.XREP) | |
s.bind('tcp://127.0.0.1:9999') | |
print 'running' | |
while True: | |
zmqid = s.recv() | |
s.recv() | |
msg = s.recv() | |
s.send(zmqid, flags=zmq.SNDMORE) | |
s.send('maybe') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment