GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — cpp-patterns/python_zmq_communication/test.py at master · hmenke/cpp-patterns Expand file tree/ Copy pathtest.pyMore file actions 53 lines (41 loc) · 1.21 KB / Copy pathtest.pyFile metadata and controls53 lines (41 loc) · 1.21 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 from PyQt5 import QtCore, QtGui import time import zmq import multiprocessing import python_zmq_communication as pzc class Worker(QtCore.QThread): def __init__(self, parent=None): super().__init__(parent) def execute(self, stdout): self.stdout = stdout self.start() def run(self): for line in self.stdout: print(line) if ">>END" in line: break class Communicator: def __init__(self, socket): self.socket = socket def __iter__(self): return self def __next__(self): string = self.socket.recv_string() if ">>END" in string: raise StopIteration else: return string if __name__ == '__main__': multiprocessing.freeze_support() context = zmq.Context() socket = context.socket(zmq.SUB) socket.bind("tcp://127.0.0.1:*") socket.setsockopt_string(zmq.SUBSCRIBE, u"") endpoint = socket.getsockopt_string(zmq.LAST_ENDPOINT) print("Binding via {}".format(endpoint)) thread = Worker() proc = multiprocessing.Process(target=pzc.perform, args=(1,endpoint)) proc.start() thread.execute(Communicator(socket)) thread.wait() proc.join() |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |