سؤال

My object:

class mysrv(object):
    def __init__(self):
        self._pubsocket = context.socket(zmq.PUB)
        self._socket = context.socket(zmq.REP)
        self._socket.bind("tcp://127.0.0.1:9003")
        self._pubsocket.bind("tcp://127.0.0.1:9004")

Then I run both functions:

def main():
    s = mysrv()
    Process(target=s.publoop()).start()
    Process(target=s.reqrep()).start()

The first function blocks the second. Is there any way to run them from a single class instance?

هل كانت مفيدة؟

المحلول

The answer is that while will block everything even sleep is called.

So, running many whiles in the same process without breaks is blocking.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top