Skip to content

Instantly share code, notes, and snippets.

@alper
Created August 10, 2012 11:23
Show Gist options
  • Save alper/3313566 to your computer and use it in GitHub Desktop.
Save alper/3313566 to your computer and use it in GitHub Desktop.
Simplified zeromq PUSH/PULL example
import sys
import time
import zmq
context = zmq.Context()
# Socket to receive messages on
receiver = context.socket(zmq.PULL)
receiver.bind("tcp://*:5558")
while True:
print receiver.recv()
import zmq
import random
import time
context = zmq.Context()
# Socket with direct access to the sink: used to syncronize start of batch
sink = context.socket(zmq.PUSH)
sink.connect("tcp://localhost:5558")
# Initialize random number generator
random.seed()
while True:
workload = random.randint(1, 100)
sink.send(str(workload))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment