Created
June 12, 2012 04:57
-
-
Save kbourgoin/2915148 to your computer and use it in GitHub Desktop.
zerorpc Pusher tester
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
# To run pusher and puller: start with "push" or "pull" as arguments | |
# Note how pusher blocks until puller starts and then memory grows unbounded | |
# | |
# To see HWM setting: | |
# Add "self.setsockopt(_zmq.HWM, 10)" to line 49 in gevent_zeromq.py | |
# NOTE: Line 15 below doesn't work and I don't know why. | |
import zmq | |
from zerorpc import Pusher, Puller | |
def push(): | |
import time | |
p = Pusher() | |
# p._events._socket.setsockopt(zmq.HWM, 10) # I have no idea why this doesn't work | |
p.bind('tcp://127.0.0.1:8080') | |
i = 0 | |
while True: | |
print 'sending %i' % i | |
p('test', ('received %i.' % i)*100000) # Huge to see memory usage | |
i += 1 | |
time.sleep(0.1) | |
class TestPuller(object): | |
def test(self, msg): | |
print msg.split('.', 1)[0] | |
import time; time.sleep(2) | |
if __name__ == '__main__': | |
import sys | |
if sys.argv[1] == 'push': | |
push() | |
elif sys.argv[1] == 'pull': | |
p = Puller(TestPuller()) | |
p .connect('tcp://127.0.0.1:8080') | |
p .run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment