minrk on move-wepoll
minrk on main
bundle wepoll the same way we d… try testing wheels for ipc supp… Merge pull request #1576 from z… (compare)
minrk on main
run pre-commit on pre-commit.ci… Merge pull request #1575 from m… (compare)
minrk on move-wepoll
bundle wepoll the same way we d… try testing wheels for ipc supp… (compare)
minrk on main
Updating bundle.py to use v142 … Merge pull request #1574 from m… (compare)
i think what i need is CurveZMQ and since i want to use it with pub/sub i'd need it in the transport layer i guess.
To secure a single hop between client and server, which is the CurveCP use case. For this use case we would embed CurveZMQ in the transport layer so that it can work for all patterns (publish-subscribe, pipeline, and so on).
import threading
from multiprocessing import Process
import zmq
def step1(context=None):
"""Step 1"""
context = context or zmq.Context.instance()
# Signal downstream to step 2
sender = context.socket(zmq.PAIR)
sender.connect("inproc://step2")
sender.send(b"from step1")
def step2(context=None):
"""Step 2"""
context = context or zmq.Context.instance()
# Bind to inproc: endpoint, then start upstream thread
receiver = context.socket(zmq.PAIR)
receiver.bind("inproc://step2")
#thread = threading.Thread(target=step1)
thread = Process(target=step1, args=(context,))
thread.start()
# Wait for signal
msg = receiver.recv()
print("%s" % msg)
# Signal downstream to step 3
sender = context.socket(zmq.PAIR)
sender.connect("inproc://step3")
sender.send(b"from step2")
def main():
""" server routine """
# Prepare our context and sockets
context = zmq.Context.instance()
# Bind to inproc: endpoint, then start upstream thread
receiver = context.socket(zmq.PAIR)
receiver.bind("inproc://step3")
#thread = threading.Thread(target=step2)
thread = Process(target=step2, args=(context,))
thread.start()
# Wait for signal
msg = receiver.recv()
print("%s" % msg)
print("Test successful!")
receiver.close()
context.term()
if __name__ == "__main__":
main()
So far this example (changed with multiprocessing in mind) fails. I took, and changed it from here: https://github.com/companycy/cpp_by_example/blob/master/inproc_example.py
It gives this result:
Assertion failed: ok (src/mailbox.cpp:99)
Assertion failed: ok (src/mailbox.cpp:99)
[1] 3015255 abort (core dumped) python test-pymq.py
inproc connection using the multiprocessing module in Python?
inproc is in-process, it can't be used across processes, which includes forks created by multiprocessing. Contexts cannot be passed across forks, either. You'll need to use the ipc or tcp transports for inter-process communication, and start a Context in each process.
recv()
statement even though the REQ
side successfully reconnects to the REP
.socat
port-forward, and break it arbitrarily. It results in a broken state most of the times.