pyzmq

How can I use send_json with pyzmq PUB SUB

风格不统一 提交于 2019-12-04 18:34:39
I need to send a dictionary as the message from a publisher to subscribers. With the REQ/REP pattern send_json and recv_json work nicely, but I can't seem to find an incantation that works for PUB/SUB. Hope it's not the case that PUB/SUB can only work with send() and recv(). Here's the listing for the experiment I put together: """ Experiments with 0MQ PUB/SUB pattern """ import os import sys import time import zmq from multiprocessing import Process from random import sample, choice import signal def handler(signum, frame): """ Handler for SIGTERM """ # kill the processes we've launched try:

How to have limited ZMQ (ZeroMQ - PyZMQ) queue buffer size in python?

拟墨画扇 提交于 2019-12-04 17:01:16
I use pyzmq library with pub/sub in python . I have some rapid ZMQ publisher by .connect() method script and a slower ZMQ subscriber by .bind() method script. Then after few minutes my subscriber gets old published data from publishers ( due ZMQ buffer ). My Question: Is there an approach to manage ZMQ queue buffer size? (set a limited buffer) Note : I don't want to use ZMQ PUSH/PULL. Note : I've read this post, but this approach clear buffer only: clear ZMQ buffer Note : I tried with high water mark options too, but it didn't worked: socket.setsockopt(zmq.RCVHWM, 10) # not working socket

ImportError: cannot import name constants

非 Y 不嫁゛ 提交于 2019-12-04 14:36:37
I'm trying to run a simple piece of code using pyzmq. I am using Python 2.7 and pyzmq 14.5 $ python --version Python 2.7.6 $ sudo find /usr -name "*pyzmq*" /usr/local/lib/python2.7/dist-packages/pyzmq-14.5.0.egg-info /usr/lib/python2.7/dist-packages/pyzmq-14.0.1.egg-info Following is the code i'm trying to run: import zhelpers context = zmq.Context.instance() server = context.socket(zmq.ROUTER) server.bind("tcp://*:5678") while (1): address, empty, data = server.recv_multipart() print("address = %s, data = %d" % (address, int(data))) data_i = int(data) + 10 server.send_multipart([ address, b''

Are there any Python 2.7 alternatives to ZeroMQ that are released under the BSD or MIT license?

梦想的初衷 提交于 2019-12-04 10:16:40
I am seeking Python 2.7 alternatives to ZeroMQ that are released under the BSD or MIT license. I am looking for something that supports request-reply and pub-sub messaging patterns. I can serialize the data myself if necessary. I found Twisted from Twisted Matrix Labs but it appears to require a blocking event loop, i.e. reactor.run(). I need a library that will run in the background and let my application check messages upon certain events. Are there any other alternatives? Give nanomsg , a ZeroMQ younger sister, a try - same father, same beauty Yes, it is licensed under MIT /X11 license. Yes

ZeroMQ PUB socket buffers all my out going data when it is connecting

被刻印的时光 ゝ 提交于 2019-12-04 07:59:50
问题 I noticed that a zeromq PUB socket will buffers all outgoing data if it is connecting, for example import zmq import time context = zmq.Context() # create a PUB socket pub = context.socket (zmq.PUB) pub.connect("tcp://127.0.0.1:5566") # push some message before connected # they should be dropped for i in range(5): pub.send('a message should not be dropped') time.sleep(1) # create a SUB socket sub = context.socket (zmq.SUB) sub.bind("tcp://127.0.0.1:5566") sub.setsockopt(zmq.SUBSCRIBE, "")

Jupyter notebook python crash on Windows 10

冷暖自知 提交于 2019-12-03 04:23:25
I have spent a week searching and trying different solutions with no luck. I've seen several others having the same problems going back over a year. The issue: Windows 10 Pro build 15063.674 I'm using the latest Anaconda 5 build with Python 3.6.2 and all the packages are updated to most recent. Running Jupyter Notebook, after some time, python will crash with a dialog "python has stopped working". This seems to happen after the notebook has been open for awhile, but I haven't been able to pinpoint an exact time. It's longer than 15 minutes but I've had it crash after a couple hours too. The

How could I set hwm in the push/pull pattern of zmq?

余生颓废 提交于 2019-12-02 06:20:53
I have found a similar question, ZeroMQ: HWM on PUSH does not work , but it couldn't solve my problem. I want to control the number of messages that the push socket queues, but it doesn't work and still queues 1000 messages. So I want to know how to set the hwm of the push socket. Thanks in advance. My environment is: libzmq 4.0.4, pyzmq 14.1.0, python 3.3 Here's my code: server.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- import random import zmq class TestPush(object): def __init__(self): self.ctx = zmq.Context() random.seed() def run(self): task_snd = self.ctx.socket(zmq.PUSH) task_snd

Error installing ZeroMQ

左心房为你撑大大i 提交于 2019-12-02 02:52:11
问题 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/zmq/__init__.py", line 51, in <module> from zmq import core, devices File "/usr/local/lib/python2.7/dist-packages/zmq/core/__init__.py", line 26, in <module> from zmq.core import (constants, error, message, context, ImportError: /usr/local/lib/python2.7/dist-packages/zmq/core/socket.so: undefined symbol: zmq_sendmsg I am getting above error. I have followed steps given on the

pyzmq installation error

非 Y 不嫁゛ 提交于 2019-12-01 14:00:14
I receive an error when trying to import zmq : Traceback (most recent call last): File "BasicPub.py", line 1, in <module> import zmq File "/home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq/__init__.py", line 66, in <module> from zmq import backend File "/home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq/backend/__init__.py", line 40, in <module> reraise(*exc_info) File "/home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq/backend/__init__.py", line 27, in <module> _ns = select_backend(first) File "/home/przemek/Enthought

pyzmq installation error

爱⌒轻易说出口 提交于 2019-12-01 13:07:40
问题 I receive an error when trying to import zmq : Traceback (most recent call last): File "BasicPub.py", line 1, in <module> import zmq File "/home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq/__init__.py", line 66, in <module> from zmq import backend File "/home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq/backend/__init__.py", line 40, in <module> reraise(*exc_info) File "/home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq