Skip to content

Instantly share code, notes, and snippets.

@minrk
Created May 25, 2023 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minrk/f4160936c5b644261a7684558f34a78a to your computer and use it in GitHub Desktop.
Save minrk/f4160936c5b644261a7684558f34a78a to your computer and use it in GitHub Desktop.
FROM python:3.10
# install libzmq with drafts enabled
ENV ZMQ_VERSION=4.3.4 \
PREFIX=/usr/local \
CPU_COUNT=4
RUN wget https://github.com/zeromq/libzmq/releases/download/v${ZMQ_VERSION}/zeromq-${ZMQ_VERSION}.tar.gz -O libzmq.tar.gz \
&& tar -xzf libzmq.tar.gz \
&& cd zeromq-${ZMQ_VERSION} \
&& ./configure --prefix=${PREFIX} --enable-drafts \
&& make -j${CPU_COUNT} \
&& make install
# install pyzmq with drafts enabled
ENV ZMQ_PREFIX=${PREFIX} \
ZMQ_DRAFT_API=1
RUN pip install -v --no-binary pyzmq --pre pyzmq
# add test script
COPY test.py /tmp/test.py
import time
import zmq
ctx = zmq.Context.instance()
radio = ctx.socket(zmq.RADIO)
dish = ctx.socket(zmq.DISH)
dish.rcvtimeo = 1_000 # 1 second timeout
dish.bind('udp://*:64067')
dish.join('1')
radio.connect('udp://127.0.0.1:64067')
for i in range(10):
time.sleep(0.1)
radio.send(f'{i:03}'.encode('ascii'), group='1')
msg = dish.recv_string()
print("received", msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment