Skip to content

Commit

Permalink
I will not apologize for art.
Browse files Browse the repository at this point in the history
  • Loading branch information
AIJIJI committed Apr 25, 2018
1 parent 87195f8 commit 130c0c2
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -18,3 +18,4 @@ book.tex
upload.sh
changes.txt
*.swp
testdata*
1 change: 0 additions & 1 deletion examples/Python/asyncrrhandlers.py
Expand Up @@ -171,4 +171,3 @@ def main():

if __name__ == "__main__":
main()

2 changes: 1 addition & 1 deletion examples/Python/clonecli3_py3.py
@@ -1,4 +1,4 @@
# coding=utf-8
# coding=utf-8
"""
Clone client Model Three
Author: Min RK <benjaminrk@gmail.com
Expand Down
2 changes: 1 addition & 1 deletion examples/Python/clonesrv3_py3.py
@@ -1,4 +1,4 @@
# coding=utf-8
# coding=utf-8

"""
Clone server Model Three
Expand Down
15 changes: 7 additions & 8 deletions examples/Python/dechat.py
Expand Up @@ -10,18 +10,18 @@

def listen(masked):
"""listen for messages
masked is the first three parts of an IP address:
192.168.1
The socket will connect to all of X.Y.Z.{1-254}.
"""
ctx = zmq.Context.instance()
listener = ctx.socket(zmq.SUB)
for last in range(1, 255):
listener.connect("tcp://{0}.{1}:9000".format(masked, last))

listener.setsockopt(zmq.SUBSCRIBE, b'')
while True:
try:
Expand All @@ -42,12 +42,12 @@ def main():
inet = ifaddresses(args.interface)[AF_INET]
addr = inet[0]['addr']
masked = addr.rsplit('.', 1)[0]

ctx = zmq.Context.instance()

listen_thread = Thread(target=listen, args=(masked,))
listen_thread.start()

bcast = ctx.socket(zmq.PUB)
bcast.bind("tcp://%s:9000" % args.interface)
print("starting chat on %s:9000 (%s.*)" % (args.interface, masked))
Expand All @@ -62,4 +62,3 @@ def main():

if __name__ == '__main__':
main()

4 changes: 2 additions & 2 deletions examples/Python/eagain.py
Expand Up @@ -8,15 +8,15 @@ def main():
mailbox.sndhwm = 4
mailbox.sndtimeo = 0
mailbox.connect("tcp://localhost:9876")

for count in range(10):
print("Sending message %i" % count)
try:
mailbox.send(b"message %i" % count)
except zmq.Again as e:
print(e)
break

ctx.destroy(linger=0)

if __name__ == '__main__':
Expand Down
1 change: 0 additions & 1 deletion examples/Python/interface.py
Expand Up @@ -143,4 +143,3 @@ def reap_peers(self):
print("reaping %s" % peer.uuid, peer.expires_at, now)
self.peers.pop(peer.uuid)
self.pipe.send_multipart([b'LEFT', peer.uuid])

1 change: 0 additions & 1 deletion examples/Python/interrupt.py
Expand Up @@ -18,4 +18,3 @@
# clean up
socket.close()
context.term()

10 changes: 5 additions & 5 deletions examples/Python/kvmsg.py
Expand Up @@ -70,7 +70,7 @@ def get(self, k, default=None):
return self.properties.get(k, default)

def store(self, dikt):
"""Store me in a dict if I have anything to store
"""Store me in a dict if I have anything to store
else delete me from the dict."""
if self.key is not None and self.body is not None:
dikt[self.key] = self
Expand Down Expand Up @@ -99,15 +99,15 @@ def from_msg(cls, msg):
body = body if body else None
prop = decode_properties(prop_s)
return cls(seq, uuid=uuid, key=key, properties=prop, body=body)

def __repr__(self):
if self.body is None:
size = 0
data=b'NULL'
else:
size = len(self.body)
data = repr(self.body)

mstr = "[seq:{seq}][key:{key}][size:{size}][props:{props}][data:{data}]".format(
seq=self.sequence,
# uuid=hexlify(self.uuid),
Expand All @@ -117,8 +117,8 @@ def __repr__(self):
data=data,
)
return mstr


def dump(self):
print("<<", str(self), ">>", file=sys.stderr)
# ---------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions examples/Python/peering2.py
Expand Up @@ -88,8 +88,8 @@ def main(myself, peers):
for peer in peers:
tprint("I: connecting to cloud frontend at %s" % peer)
cloudbe.connect("ipc://%s-cloud.ipc" % peer)


if not isinstance(peers[0], bytes):
peers = [peer.encode('ascii') for peer in peers]

Expand Down
3 changes: 1 addition & 2 deletions examples/Python/rtreq.py
Expand Up @@ -51,7 +51,7 @@ def worker_thread(context=None):
for _ in range(NBR_WORKERS * 10):
# LRU worker is next waiting in the queue
address, empty, ready = client.recv_multipart()

client.send_multipart([
address,
b'',
Expand All @@ -66,4 +66,3 @@ def worker_thread(context=None):
b'',
b'END',
])

1 change: 0 additions & 1 deletion examples/Python/udplib.py
Expand Up @@ -38,4 +38,3 @@ def recv(self, n):
if addrinfo[0] != self.address:
print("Found peer %s:%d" % addrinfo)
return buf

2 changes: 1 addition & 1 deletion examples/Python/udpping3.py
Expand Up @@ -15,4 +15,4 @@ def main():
interface.stop()

if __name__ == '__main__':
main()
main()

0 comments on commit 130c0c2

Please sign in to comment.