Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't need this anymore

  • Loading branch information...
commit 8b07d7825d29fa4d00435031833fc2b87a9eede8 1 parent 1f5ade7
Eric Stein authored
Showing with 0 additions and 78 deletions.
  1. +0 −78 zmqsub.py
78 zmqsub.py
View
@@ -1,78 +0,0 @@
-import zmq
-import json
-
-class NoMessagesException(Exception) :
- pass
-
-class JSONZMQSub(object) :
- def __init__(self, url) :
- self.c = zmq.Context(1)
- self.s = self.c.socket(zmq.SUB)
- self.s.connect(url)
- self.s.setsockopt (zmq.SUBSCRIBE, "")
- self._last = None
-
- def last_msg(self) :
- r = [self.s]
- msg = None
- while r :
- r, w, x = zmq.core.poll.select([self.s], [], [], 0.0)
- if r :
- msg = self.s.recv()
-
- r, w, x = zmq.core.poll.select([self.s], [], [], 0.05)
- if r :
- msg = self.s.recv()
-
- if msg is not None :
- self._last = json.loads(msg)
-
- return self._last
-
- def recv(self) :
- msg = None
- r, w, x = zmq.core.poll.select([self.s], [], [], 0.0)
- if r :
- msg = self.s.recv()
- self._last = json.loads(msg)
- return self._last
- else :
- raise NoMessagesException
-
-class JSONZMQBindSub(object) :
- def __init__(self, url) :
- self.c = zmq.Context(1)
- self.s = self.c.socket(zmq.SUB)
- self.s.bind(url)
- self.s.setsockopt (zmq.SUBSCRIBE, "")
-
- def recv(self) :
- msg = None
- r, w, x = zmq.core.poll.select([self.s], [], [], 0.0)
- if r :
- msg = self.s.recv()
- self._last = json.loads(msg)
- return self._last
- else :
- raise NoMessagesException
-
-class JSONZMQBindPub(object) :
- def __init__(self, url) :
- self.c = zmq.Context(1)
- self.s = self.c.socket(zmq.PUB)
- self.s.bind(url)
-
- def send(self, msg) :
- self.s.send(json.dumps(msg))
-
-class JSONZMQConnectPub(object) :
- def __init__(self, url) :
- self.c = zmq.Context(1)
- self.s = self.c.socket(zmq.PUB)
- self.s.connect(url)
-
- # unreliable send, but won't block forever.
- def send(self, msg) :
- r, w, x = zmq.core.poll.select([], [self.s], [], 10.0)
- if w :
- self.s.send(json.dumps(msg))
Please sign in to comment.
Something went wrong with that request. Please try again.