Coder Social home page Coder Social logo

zeromq / pyzmq Goto Github PK

View Code? Open in Web Editor NEW
3.5K 102.0 625.0 6.78 MB

PyZMQ: Python bindings for zeromq

Home Page: http://zguide.zeromq.org/py:all

License: BSD 3-Clause "New" or "Revised" License

Python 85.35% C 1.37% Jupyter Notebook 5.04% Makefile 0.34% Batchfile 0.54% Dockerfile 0.03% Shell 0.31% Cython 3.22% CMake 3.79%
cython python zeromq

pyzmq's Introduction

PyZMQ: Python bindings for ØMQ

This package contains Python bindings for ZeroMQ. ØMQ is a lightweight and fast messaging implementation.

PyZMQ should work with any reasonable version of Python (≥ 3.7), as well as PyPy. The Cython backend used by CPython supports libzmq ≥ 2.1.4 (including 3.2.x and 4.x), but the CFFI backend used by PyPy only supports libzmq ≥ 3.2.2 (including 4.x).

For a summary of changes to pyzmq, see our changelog.

ØMQ 3.x, 4.x

PyZMQ fully supports the 3.x and 4.x APIs of libzmq, developed at zeromq/libzmq. No code to change, no flags to pass, just build pyzmq against the latest and it should work.

PyZMQ does not support the old libzmq 2 API on PyPy.

Documentation

See PyZMQ's Sphinx-generated documentation on Read the Docs for API details, and some notes on Python and Cython development. If you want to learn about using ØMQ in general, the excellent ØMQ Guide is the place to start, which has a Python version of every example. We also have some information on our wiki.

Downloading

Unless you specifically want to develop PyZMQ, we recommend downloading the PyZMQ source code or wheels from PyPI, or install with conda.

You can also get the latest source code from our GitHub repository, but building from the repository will require that you install recent Cython.

Building and installation

For more detail on building pyzmq, see our docs.

We build wheels for macOS, Windows, and Linux, so you can get a binary on those platforms with:

pip install pyzmq

but compiling from source with pip install pyzmq should work in most environments. Make sure you are using the latest pip, or it may not find the right wheels.

If the wheel doesn't work for some reason, or you want to force pyzmq to be compiled (this is often preferable if you already have libzmq installed and configured the way you want it), you can force installation from source with:

pip install --no-binary=pyzmq pyzmq

Old versions

pyzmq 16 drops support Python 2.6 and 3.2. If you need to use one of those Python versions, you can pin your pyzmq version to before 16:

pip install 'pyzmq<16'

For libzmq 2.0.x, use 'pyzmq<2.1'

pyzmq-2.1.11 was the last version of pyzmq to support Python 2.5, and pyzmq ≥ 2.2.0 requires Python ≥ 2.6. pyzmq-13.0.0 introduces PyPy support via CFFI, which only supports libzmq-3.2.2 and newer.

PyZMQ releases ≤ 2.2.0 matched libzmq versioning, but this is no longer the case, starting with PyZMQ 13.0.0 (it was the thirteenth release, so why not?). PyZMQ ≥ 13.0 follows semantic versioning conventions accounting only for PyZMQ itself.

pyzmq's People

Contributors

akindofyoga avatar alexrudy avatar amrali avatar andrelouiscaron avatar asteven avatar bluca avatar cclauss avatar cgohlke avatar claws avatar dcsaba89 avatar dependabot[bot] avatar desmoteo avatar ellisonbg avatar fperez avatar guidog avatar iblislin avatar itziakos avatar juliantaylor avatar messa avatar michelp avatar minrk avatar pembem22 avatar phuslu avatar pre-commit-ci[bot] avatar rainwoodman avatar randallpittman avatar sakurai-youhei avatar sfriesel avatar sublee avatar takluyver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyzmq's Issues

warnings during compile

No need for warnings now is there? ;-)

ubuntu 10.4.1, git cloned just now.

jon

root@ubuntu:~/checkout/pyzmq# python setup.py build_ext --rpath=/usr/local/zeromq --inplace
running build_ext
building 'zmq._zmq' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/zeromq-dev/include -I/usr/include/python2.6 -c zmq/_zmq.c -o build/temp.linux-x86_64-2.6/zmq/_zmq.o
In file included from zmq/_zmq.c:205:
/usr/local/zeromq-dev/include/zmq.h:94: warning: function declaration isn’t a prototype
In file included from zmq/_zmq.c:206:
/usr/local/zeromq-dev/include/zmq_utils.h:42: warning: function declaration isn’t a prototype
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-x86_64-2.6/zmq/_zmq.o -L/usr/local/zeromq-dev/lib -Wl,-R/usr/local/zeromq -lzmq -o /home/jon/checkout/pyzmq/zmq/_zmq.so

Python2.5 _zmq.so undefined symbol PyObject_GetBuffer

When compiling via setup.py (either using the bundled .c sources, or generating new ones using Cython), possibly unused references remain in _zmq.so pointing to PyObject_GetBuffer and PyObject_CheckBuffer.

Therefore "import zmq" fails. When manually removing the respective methods from the cdef extend section of buffer.pxd (and defining dummy raise "error" functions with the same signature), it compiles and seems to be running fine (although not thoroughly tested). Therefore some kind of conditional inclusion based on python version would be nice.

Zeroconf (using Avahi) example

Below is an example showing how to use PyZMQ with Avahi for Zeroconf. The example is loosely based on the Python examples on avahi.org:

http://www.avahi.org/wiki/PythonPublishExample
http://www.avahi.org/wiki/PythonBrowseExample

The example is unfinished and needs cleaning up, but I'm posting it here as requested by Brian:

http://lists.zeromq.org/pipermail/zeromq-dev/2010-September/006175.html

#!/usr/bin/env python

# This is an example Avahi (zeroconf) extension for pyzmq.

# FIXME: This hasn't seen much love lately and really needs some
# move work. zmqconf could subclass pyzmq so that bind announces
# the service and connect discovers the service - using names
# instead of connection strings (eg. "tcp://192.168.0.1:5555").

# Copyright (C) 2010 David Robinson <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

import dbus
import gobject
import avahi    # ey, provided by dbus-ui-tools package on Fedora?!
from dbus import DBusException
from dbus.mainloop.glib import DBusGMainLoop
from threading import Thread

MAX_RENAMES = 12

class zmqconf:

    def __init__(self, domain='', host=''):
        self.domain = domain
        self.host = host
        self.rename_count = MAX_RENAMES
        self._services = []
        self.group = None

        DBusGMainLoop(set_as_default=True)
        gobject.threads_init()
        dbus.mainloop.glib.threads_init()
        self.main_loop = gobject.MainLoop()
        self.bus = dbus.SystemBus()

        self.server = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER)
        self.server.connect_to_signal("StateChanged", self._server_state_changed)
        self._server_state_changed(self.server.GetState())

        t = Thread(target=self.main_loop.run)
        t.setDaemon(True)
        t.start()

    def browse_services(self, type, domain=''):
        sbrowser = dbus.Interface(
                self.bus.get_object(
                    avahi.DBUS_NAME,
                    self.server.ServiceBrowserNew(
                        avahi.IF_UNSPEC,
                        avahi.PROTO_UNSPEC,
                        type, domain,
                        dbus.UInt32(0))
                    ),
                avahi.DBUS_INTERFACE_SERVICE_BROWSER)
        sbrowser.connect_to_signal("ItemNew", self._myhandler)

    def close(self):
        """Close the socket.

        This can be called to close the socket by hand. If this is not
        called, the socket will automatically be closed when it is
        garbage collected.
        """
        # We can overwrite closing here
        pass

    def bind(self, addr):
        """Bind the socket to an address.

        This causes the socket to listen on a network port. Sockets on the
        other side of this connection will use :meth:`Socket.connect` to
        connect to this socket.

        Parameters
        ----------
        addr : str
            The address string. This has the form 'protocol://interface:port',
            for example 'tcp://127.0.0.1:555'. Protocols supported are
            tcp, upd, pgm, iproc and ipc.
        """

        # Zeroconf doesn't makes sense for some transports
        if addr[:3].lower() == 'ipc':
            raise Exception("Cannot use Zeroconf with IPC")
        elif addr[:5].lower() == 'inproc':
            raise Exception("Cannot use Zeroconf with inproc")

        # bind to the socket
        #port = addr[addr.rindex(':') + 1:]
        #proto = addr[:addr.index(':')]
        # if the bind was successful (it'll raise an exception if not) publish details
        proto, host, port = addr.split(':')
        self.add_service("Example Service", "_example._tcp", 5555, "somethingcrazy")
        #self.add_service("Example", proto, int(port), addr)


    def _service_resolved(self, *args):
        print 'service resolved'
        print 'name:', args[2]
        print 'address:', args[7]
        print 'port:', args[8]

    def _print_error(self, *args):
        print args[0]

    def _myhandler(self, interface, protocol, name, stype, domain, flags):
        print "Found service '%s' type '%s' domain '%s' " % (name, stype, domain)
        if flags & avahi.LOOKUP_RESULT_LOCAL:
            # local service, skip
            pass

        self.server.ResolveService(interface, protocol, name, stype,
            domain, avahi.PROTO_UNSPEC, dbus.UInt32(0),
            reply_handler=self._service_resolved, error_handler=self._print_error)

    def _add_services(self):
        for service in self._services:
            name, type, port, txt = service
            self.add_service(name, type, port, txt)

    def add_service(self, name, proto, port, txt):
        print "Adding service '%s' of type '%s' ..." % (name, proto)
        if self.group is None:
            #self.bus = dbus.SystemBus()
            #ob = self.bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER)
            #self.server = dbus.Interface(ob, avahi.DBUS_INTERFACE_SERVER)
            #eg = self.server.EntryGroupNew()
            #ob = self.bus.get_object(avahi.DBUS_NAME, eg)
            #self.group = dbus.Interface(ob, avahi.DBUS_INTERFACE_ENTRY_GROUP)
            self.group = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.EntryGroupNew()), avahi.DBUS_INTERFACE_ENTRY_GROUP)
            self.group.connect_to_signal('StateChanged', self._entry_group_state_changed)
        self.group.AddService(
                avahi.IF_UNSPEC,                # interface
                avahi.PROTO_UNSPEC,             # protocol
                dbus.UInt32(0),                 # flags
                name, proto,
                self.domain, self.host,
                dbus.UInt16(port),
                avahi.string_array_to_txt_array(txt))
        self.group.Commit()
        self._services.append((name, proto, port, txt))

    def remove_services(self):
        #global group
        if not self.group is None:
            self.group.Reset()
        self._services = []

    def _server_state_changed(self, state):
        if state == avahi.SERVER_COLLISION:
            print "WARNING: Server name collision"
            self.remove_services()
        elif state == avahi.SERVER_RUNNING:
            self._add_services()

    def _entry_group_state_changed(self, state, error):
        if state == avahi.ENTRY_GROUP_ESTABLISHED:
            print "Service established."
        elif state == avahi.ENTRY_GROUP_COLLISION:

            self.rename_count -= 1
            if self.rename_count > 0:
                self.name = server.GetAlternativeServiceName(self.name)
                print "WARNING: Service name collision, changing name to '%s' ..." % self.name
                self.remove_services()
                self._add_services()
            else:
                print "ERROR: No suitable service name found after retrying, exiting."
                self.main_loop.quit()
        elif state == avahi.ENTRY_GROUP_FAILURE:
            print "Error in group state changed", error
            self.main_loop.quit()
            return

if __name__ == "__main__":
    # Publish a service
    #context = zmq.Context(1, 1)
    s = zmqconf()
    address = "tcp://lo:5555"
    #s.bind(address)
    s.add_service("Example Service", "_example._tcp", 5555, "somethingcrazy")
    raw_input("Press any key to exit")

    # Discover services
    #context = zmq.Context(1, 1)
    #s = zmqconf()
    #s.browse_services("_example._tcp")
    #raw_input("Press any key to exit")

tag 2.0.8?

Hello! I saw that 2.0.8 was made, but there's no corresponding tag. Could a tag for the release be made?

Handling server deaths in simple XREQ-XREP scenario.

I have a client (XREQ) and a server (XREP). I want to do error handling at the client, which means that the client should notice when a server is gone.

=> I cant use socket.recv() at client, as otherwise the client will block for ever when sending a msg to a death server
=> I make use of zmq.NOBLOCK

My Testcase consists of two little scripts, a server and a client: https://gist.github.com/734639

Start the client: python client.py tcp://127.0.0.1:8000 tcp://127.0.0.1:8001
Now, only start one server: python server.py tcp://127.0.0.1:8000

The XREQ socket itself does not notice that the one server is not available. As this socket is loadbalancing, every second message is send to the non-existing server. My client handles this, by resending in case it encountered a certain timout while waiting for a reply.

=> I spoke with some people at the zmq-irc and they were all like "ZMQ should notice the serverdeath and handle it for you"
=> obviously, it is not, as the client sends to server A gets a response, sends to server B (death), runs in timeout, resends the message to server A, sends the next message to server B again, gets timeout and so on.

So the question is, how to handle this properly? As far as I know, there is no way of disconnecting from one particular address manually.

Please correct me if I misunderstood something.

Thanks,

  • Toni

test_buffer_numpy in zmq.tests.test_message.TestMessage fails

I have run the test suite after my build and encountered a failed test. What is the impact of the test failure?

Regards, Andreas

setup.py build_ext --inplace
setup.py test
...
======================================================================
FAIL: test_buffer_numpy (zmq.tests.test_message.TestMessage)
test non-copying numpy array messages
----------------------------------------------------------------------
Traceback (most recent call last):
  File "E:\Dist\pyzmq-2.1.1\zmq\tests\test_message.py", line 264, in test_buffer_numpy
    self.assertEquals(A.data, m.buffer)
AssertionError: <read-write buffer for 0x0337CFC8, size 80, offset 0 at 0x03341140> != <memory at 0x010BDE40\>

----------------------------------------------------------------------
Ran 70 tests in 10.109s

FAILED (failures=1)

I am using:

  • zeromq-2.1.1
  • pymzq-2.1.1
  • Visual Studio 2008
  • Windows XP SP3

Compilation was successful. The I copied libzmq.dll to the PATH.

recv(flags=zmq.NOBLOCK) and recv_multi_parts(flags=zmq.NOBLOCK) throwing except

line 414 & 470 of zmq/core/socket.pyx state...

If NOBLOCK is set, this method will return None if a message is not ready. If NOBLOCK is not set, then this method will block until a message arrives.

New to git so don't know how to submit a patch but for example

    parts = []
    while True:
        try:
            part = self.recv(flags, copy=copy)
            parts.append(part)
            if self.rcvmore():
                continue
            else:
                break
        except zmq.ZMQError, e:
          if e.errno == zmq.EAGAIN:
            return None
          else:
            raise e
    return parts

seems to work for recv_multipart(). I may have missed something.

pyzmq compile failed

archlinux
gcc (GCC) 4.5.2
Python 2.7.1
cython 0.14-1
pyzmq version: 42a1472

Cloning into /var/abs/local/yaourtbuild/pyzmq-git/src/pyzmq-build...
done.
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/zmq
copying zmq/init.py -> build/lib.linux-x86_64-2.7/zmq
creating build/lib.linux-x86_64-2.7/zmq/tests
copying zmq/tests/test_pair.py -> build/lib.linux-x86_64-2.7/zmq/tests
copying zmq/tests/test_context.py -> build/lib.linux-x86_64-2.7/zmq/tests
copying zmq/tests/test_poll.py -> build/lib.linux-x86_64-2.7/zmq/tests
copying zmq/tests/test_multipart.py -> build/lib.linux-x86_64-2.7/zmq/tests
copying zmq/tests/init.py -> build/lib.linux-x86_64-2.7/zmq/tests
copying zmq/tests/test_socket.py -> build/lib.linux-x86_64-2.7/zmq/tests
copying zmq/tests/test_pubsub.py -> build/lib.linux-x86_64-2.7/zmq/tests
copying zmq/tests/test_message.py -> build/lib.linux-x86_64-2.7/zmq/tests
copying zmq/tests/test_reqrep.py -> build/lib.linux-x86_64-2.7/zmq/tests
creating build/lib.linux-x86_64-2.7/zmq/eventloop
copying zmq/eventloop/zmqstream.py -> build/lib.linux-x86_64-2.7/zmq/eventloop
copying zmq/eventloop/ioloop.py -> build/lib.linux-x86_64-2.7/zmq/eventloop
copying zmq/eventloop/init.py -> build/lib.linux-x86_64-2.7/zmq/eventloop
copying zmq/eventloop/win32_support.py -> build/lib.linux-x86_64-2.7/zmq/eventloop
running build_ext
cythoning zmq/_zmq.pyx to zmq/_zmq.c
warning: /var/abs/local/yaourtbuild/pyzmq-git/src/pyzmq-build/zmq/_zmq.pyx:27:0: 'stdlib' is deprecated, use 'libc.stdlib'
warning: /var/abs/local/yaourtbuild/pyzmq-git/src/pyzmq-build/zmq/_zmq.pyx:28:0: 'python_string' is deprecated, use 'cpython'
warning: /var/abs/local/yaourtbuild/pyzmq-git/src/pyzmq-build/zmq/_zmq.pyx:31:0: 'python_ref' is deprecated, use 'cpython'

Error compiling Cython file:

...

#-------------------------------------------------------------------------
# Sending and receiving messages
#-------------------------------------------------------------------------

def send(self, object data, int flags=0, bool copy=True):
                                        ^

/var/abs/local/yaourtbuild/pyzmq-git/src/pyzmq-build/zmq/_zmq.pyx:612:45: 'bool' is not a type identifier
building 'zmq._zmq' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/zmq
gcc -pthread -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -march=x86-64 -mtune=native -O2 -pipe -fPIC -I/usr/include/python2.7 -c zmq/_zmq.c -o build/temp.linux-x86_64-2.7/zmq/_zmq.o
zmq/_zmq.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
error: command 'gcc' failed with exit status 1
Aborting...

No cython needed?

Without cython, 'python setup.py build' fails with 'file zmq/core/constants.c does not exist', which is true. Cython can build it, but without cython, it isn't there. Yet the Readme says 'Cython is not required to build pyzmq'.

Unable to build on windows

I'm unable to build zeromq successfully using these directions. I'm on Windows 7 64-bit using msvc 2008, Python 2.7, and I did have to install Cython. If I follow the directions exactly, on the step "python setup.py build_ext —inplace" I get:

C:\pyzmq>python setup.py build_ext --inplace
running build_ext
skipping 'zmq\core\constants.c' Cython extension (up-to-date)
building 'zmq.core.constants' extension
Traceback (most recent call last):
  File "setup.py", line 309, in <module>
    'Topic :: System :: Networking'
  File "c:\dev\Python27\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
...trimmed...
  File "c:\dev\Python27\lib\distutils\msvc9compiler.py", line 295, in query_vcvarsall
    raise ValueError(str(list(result.keys())))
ValueError: [u'path']

If I then first run vcvarsall I get:
C:\pyzmq>python setup.py build_ext --inplace
running build_ext
skipping 'zmq\core\constants.c' Cython extension (up-to-date)
building 'zmq.core.constants' extension
C:\dev\mvs9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Izmq\utils -Izmq\core -Izmq\devices -I.\zmq -Ic:\dev\Python27\include -Ic:
\dev\Python27\PC /Tczmq\core\constants.c /Fobuild\temp.win-amd64-2.7\Release\zmq\core\constants.obj
constants.c
zmq\core\constants.c(224) : fatal error C1083: Cannot open include file: 'zmq.h': No such file or directory
error: command 'C:\dev\mvs9.0\VC\BIN\cl.exe' failed with exit status 2

If I then change setup.cfg to read:

[build_ext]
library_dirs = .\zmq
include_dirs = ..\zeromq2\include

I get:

C:\pyzmq>python setup.py build_ext --inplace
running build_ext
skipping 'zmq\core\constants.c' Cython extension (up-to-date)
building 'zmq.core.constants' extension
C:\dev\mvs9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Izmq\utils   -Izmq\core -Izmq\devices -I..\zeromq2\include -Ic:\dev\Python27
\include -Ic:\dev\Python27\PC /Tczmq\core\constants.c /Fobuild\temp.win-amd64-2.7\Release\zmq\core\constants.obj
constants.c
zmq\core\constants.c(907) : error C2065: 'ZMQ_XPUB' : undeclared identifier
zmq\core\constants.c(919) : error C2065: 'ZMQ_XSUB' : undeclared identifier
zmq\core\constants.c(1183) : error C2065: 'ZMQ_FD' : undeclared identifier
zmq\core\constants.c(1195) : error C2065: 'ZMQ_EVENTS' : undeclared identifier
zmq\core\constants.c(1207) : error C2065: 'ZMQ_TYPE' : undeclared identifier
zmq\core\constants.c(1219) : error C2065: 'ZMQ_LINGER' : undeclared identifier
zmq\core\constants.c(1231) : error C2065: 'ZMQ_RECONNECT_IVL' : undeclared identifier
zmq\core\constants.c(1243) : error C2065: 'ZMQ_BACKLOG' : undeclared identifier
error: command 'C:\dev\mvs9.0\VC\BIN\cl.exe' failed with exit status 2

And I'm stuck. What should I try next?

ZMQError thrown when using Socket.recv(zmq.NOBLOCK)

Hello !

I am currently trying 0MQ to evaluate it for use in a Python 2.6 project. I work with pyzmq 2.0.8 on win32. I took it Christoph Gohlke's page since I have build problems.

I encountered a ZMQError: "Resource temporarily unavailable" when trying to use the socket recv() method with the zmq.NOBLOCK flag.

According to the zmq.Socket.recv() docsting:

If NOBLOCK is set, this method will return None if a message is not ready. If NOBLOCK is not set, then this method will block until a message arrives.

The documentation of zmq_recv:

If there are no messages available on the specified socket, the zmq_recv() function shall fail with errno set to EAGAIN

The code of _recv_message doesn't seem to care about the result and always raise a ZMQError :

with nogil:
    rc = zmq_recv(self.handle, &msg.zmq_msg, flags)

if rc != 0:
    raise ZMQError()
return msg

There should be a check to see if the errno is EAGAIN when the zmq.NOBLOCK flag is set.

Sorry if I misunderstood the code. I am still a newbie with ZMQ and pyzmq. I could also be an error specific to my machine. Please ask if you need precisions.

setup.cfg.template confusing

library_dirs = /usr/local/zeromq-dev/lib
include_dirs = /usr/local/zeromq-dev/include

The above seems to be confusing for newbies. What about changing it to:

library_dirs = /usr/local/lib
include_dirs = /usr/local/include

given that these are the default?

bind() and connect() reject unicode strings

The bind() and connect() methods explicitly test for isinstance(., str). I suggest that this should be changed to basestring instead and allow Cython's conversion logic to handle the ASCII encoding (and possible errors). Or test for unicode and explicitly encode it to ASCII.

Use case: I am sending around address:port configuration information using send_json() and the JSON decoding process converts my str strings to unicode strings.

2.1.1dev: Symbol not found: _zmq_errno

OSX 10.6
Python 2.7 (r27:82508, Jul 3 2010, 20:17:05)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
pyzmq: 2.1.1dev (downloaded tarball)
zmq: latest master from github

After python setup.py install, and running import zmq, I get the following error:

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/zmq/core/error.so, 2): Symbol not found: _zmq_errno
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/zmq/core/error.so
Expected in: dynamic lookup

Beta packages missing files, broken

Hi,
I have installed zmq 2.1, downloaded pyzmq-2.1.0b from https://github.com/zeromq/pyzmq/downloads. It fails to build as its missing zmqversion.py file.
Having manually downloaded the zmqversion.py from the current master branch of this repo, the build completes but importing zmq into a python script produces:

import zmq
Traceback (most recent call last):
File "", line 1, in
File "zmq/init.py", line 26, in
from zmq.utils import initthreads # initialize threads
ImportError: cannot import name initthreads

Same happens when the pyzmq is 'built in place' and the 'setup.py test' is run

error: Can't download https://github.com/downloads/zeromq/pyzmq/pyzmq-2.1.0b.zip: 403 Forbidden

I'm not sure this is the place to report this, but one of you might be able to point me in the right direction if this is not the case. Thanks.

Regards,
Lukas

$ sudo easy_install pyzmq
install_dir /usr/local/lib/python2.6/dist-packages/
Searching for pyzmq
Reading http://pypi.python.org/simple/pyzmq/
Reading http://github.com/zeromq/pyzmq
Reading http://github.com/zeromq/pyzmq/downloads
Best match: pyzmq 2.1.0b
Downloading https://github.com/downloads/zeromq/pyzmq/pyzmq-2.1.0b.zip
error: Can't download https://github.com/downloads/zeromq/pyzmq/pyzmq-2.1.0b.zip: 403 Forbidden

cannot execute windows .exe file made by py2exe

Hi,
I converted my python code which includes pyzmq into an standalone windows exe file using py2exe. When I tries to execute the file, however, I got the following error message.

I would appreciate it if anyone can give me any kind of help.
Thanks.

Joel

File "zmq__init__.pyo", line 34, in
File "zmq\core__init__.pyo", line 26, in
File "zmq\core\error.pyo", line 12, in
File "zmq\core\error.pyo", line 10, in __load
File "error.pyx", line 28, in init zmq.core.error (zmq\core\error.c:966)

ImportError: No module named strtypes

Failure to find libzmq.h files in Windows

The setup.py was updated in abc4311 to search for the libzmq.h file for version info. With the settings specified in the install directions at http://www.zeromq.org/docs:windows-installations this causes a build on Windows to fail.

It works when the header files are copied to a location specified in the setup.cfg, so probably the documentation simply needs to be updated. The behavior of the version check could also be changed to be more friendly to Windows users.

I was unsure of what the appropriate action here should be; probably just documentation updates. If anyone feels that a code change would be more appropriate, I would be happy to test some options on Windows and submit a patch

Failed compilation on OS X (Snow Leopard) - Symbol not found: _zmq_bind

After installing, importing results in:

import zmq
Traceback (most recent call last):
File "", line 1, in
File "/Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/init.py", line 26, in
from zmq import _zmq
ImportError: dlopen(/Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/_zmq.so, 2): Symbol not found: _zmq_bind
Referenced from: /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/_zmq.so
Expected in: dynamic lookup

This is ZeroMQ 2.0.7 installed from source - the same steps result in a working pyzmq on my Slackware box. Output from "python setup.py install" follows:

foxglove:pyzmq mel$ mv setup.cfg.template setup.cfg foxglove:pyzmq mel$ . ~/Projects/zerobox/bin/activate (zerobox)foxglove:pyzmq mel$ python setup.py install running install running build running build_py creating build creating build/lib.macosx-10.3-fat-2.6 creating build/lib.macosx-10.3-fat-2.6/zmq copying zmq/**init**.py -> build/lib.macosx-10.3-fat-2.6/zmq creating build/lib.macosx-10.3-fat-2.6/zmq/tests copying zmq/tests/**init**.py -> build/lib.macosx-10.3-fat-2.6/zmq/tests copying zmq/tests/test_context.py -> build/lib.macosx-10.3-fat-2.6/zmq/tests copying zmq/tests/test_message.py -> build/lib.macosx-10.3-fat-2.6/zmq/tests copying zmq/tests/test_multipart.py -> build/lib.macosx-10.3-fat-2.6/zmq/tests copying zmq/tests/test_pair.py -> build/lib.macosx-10.3-fat-2.6/zmq/tests copying zmq/tests/test_poll.py -> build/lib.macosx-10.3-fat-2.6/zmq/tests copying zmq/tests/test_pubsub.py -> build/lib.macosx-10.3-fat-2.6/zmq/tests copying zmq/tests/test_reqrep.py -> build/lib.macosx-10.3-fat-2.6/zmq/tests copying zmq/tests/test_socket.py -> build/lib.macosx-10.3-fat-2.6/zmq/tests creating build/lib.macosx-10.3-fat-2.6/zmq/eventloop copying zmq/eventloop/**init**.py -> build/lib.macosx-10.3-fat-2.6/zmq/eventloop copying zmq/eventloop/ioloop.py -> build/lib.macosx-10.3-fat-2.6/zmq/eventloop copying zmq/eventloop/win32_support.py -> build/lib.macosx-10.3-fat-2.6/zmq/eventloop copying zmq/eventloop/zmqstream.py -> build/lib.macosx-10.3-fat-2.6/zmq/eventloop running build_ext building 'zmq._zmq' extension creating build/temp.macosx-10.3-fat-2.6 creating build/temp.macosx-10.3-fat-2.6/zmq gcc-4.0 -arch ppc -arch i386 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -I/usr/zeromq/include -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c zmq/_zmq.c -o build/temp.macosx-10.3-fat-2.6/zmq/_zmq.o In file included from /usr/include/architecture/i386/math.h:626, from /usr/include/math.h:28, from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyport.h:235, from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:58, from zmq/_zmq.c:4: /usr/include/AvailabilityMacros.h:108:14: warning: #warning Building for Intel with Mac OS X Deployment Target < 10.4 is invalid. gcc-4.0 -arch ppc -arch i386 -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.6/zmq/_zmq.o -L/usr/zeromq/lib -lzmq -o build/lib.macosx-10.3-fat-2.6/zmq/_zmq.so ld: warning: in /usr/zeromq/lib/libzmq.dylib, file was built for unsupported file format which is not the architecture being linked (i386) ld: warning: in /usr/zeromq/lib/libzmq.dylib, file was built for unsupported file format which is not the architecture being linked (ppc) running install_lib creating /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq copying build/lib.macosx-10.3-fat-2.6/zmq/__init__.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq copying build/lib.macosx-10.3-fat-2.6/zmq/_zmq.so -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq creating /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/eventloop copying build/lib.macosx-10.3-fat-2.6/zmq/eventloop/__init__.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/eventloop copying build/lib.macosx-10.3-fat-2.6/zmq/eventloop/ioloop.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/eventloop copying build/lib.macosx-10.3-fat-2.6/zmq/eventloop/win32_support.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/eventloop copying build/lib.macosx-10.3-fat-2.6/zmq/eventloop/zmqstream.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/eventloop creating /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests copying build/lib.macosx-10.3-fat-2.6/zmq/tests/**init**.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests copying build/lib.macosx-10.3-fat-2.6/zmq/tests/test_context.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests copying build/lib.macosx-10.3-fat-2.6/zmq/tests/test_message.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests copying build/lib.macosx-10.3-fat-2.6/zmq/tests/test_multipart.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests copying build/lib.macosx-10.3-fat-2.6/zmq/tests/test_pair.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests copying build/lib.macosx-10.3-fat-2.6/zmq/tests/test_poll.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests copying build/lib.macosx-10.3-fat-2.6/zmq/tests/test_pubsub.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests copying build/lib.macosx-10.3-fat-2.6/zmq/tests/test_reqrep.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests copying build/lib.macosx-10.3-fat-2.6/zmq/tests/test_socket.py -> /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/**init**.py to **init**.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/eventloop/**init**.py to **init**.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/eventloop/ioloop.py to ioloop.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/eventloop/win32_support.py to win32_support.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/eventloop/zmqstream.py to zmqstream.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests/**init**.py to **init**.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests/test_context.py to test_context.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests/test_message.py to test_message.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests/test_multipart.py to test_multipart.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests/test_pair.py to test_pair.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests/test_poll.py to test_poll.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests/test_pubsub.py to test_pubsub.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests/test_reqrep.py to test_reqrep.pyc byte-compiling /Users/mel/Projects/zerobox/lib/python2.6/site-packages/zmq/tests/test_socket.py to test_socket.pyc running install_egg_info Writing /Users/mel/Projects/zerobox/lib/python2.6/site-packages/pyzmq-0.1-py2.6.egg-info

some errors bring down the whole interpreter

In certain situations, pyzmq aborts with a cryptic message and brings down python, instead of raising an exception; examples:

  • call zmq.Context() more than once in the same Python process
  • random, but reliable failures when attempting to have several DOWNSTREAM threads pushing data to an UPSTREAM collector

I am not sure this can be managed at the bindings level, but if it can, please do :) (or tell me where to look, I am willing to get my hands dirty)

'EMTHREAD' undeclared

Not sure what to say other than this is an ubuntu 10.04 system. I'm trying to install from a cloned repo.

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c zmq/_zmq.c -o build/temp.linux-i686-2.6/zmq/_zmq.o
zmq/_zmq.c: In function 'init_zmq':
zmq/_zmq.c:10242: error: 'EMTHREAD' undeclared (first use in this function)
zmq/_zmq.c:10242: error: (Each undeclared identifier is reported only once
zmq/_zmq.c:10242: error: for each function it appears in.)
error: command 'gcc' failed with exit status 1

Building pyzmq on Windows

Hi there,

While building a Windows egg for pyzmq I noticed a small issue that can be improved.

When I follow your docs, the resulting egg (or zip file when using bdist) does not include the libzmq.dll file, even if you copy it to the pyzmq/zmq directory. Adding the following to setup.py fixes this:

if sys.platform == 'win32':
    libzmq = 'libzmq'
    package_data = {'zmq': ['libzmq.dll']}  # <--- Add this
else:
    libzmq = 'zmq'
    package_data = {} # <--- Add this

and

setup(
    name = "pyzmq",
    version = "2.0.7",
    packages = ['zmq', 'zmq.tests', 'zmq.eventloop'],
    ext_modules = [zmq],
    package_data = package_data, # <--- Add this
    author = "Brian E. Granger",

(Appologies for not including a patch, I don't have diff or git or hg on this Windows box as it is not my normal development environment.) :(

With this change, once the libzmq.dll is copied to the zmq directory, per your readme, it will then be included in the binary distribution.

The alternatives are either to first do python setup.py build, copy the dll into build\lib.win32-2.6\zmq and then build the binary distribution; or manually copy the dll to every intallation of the egg as a seperate step (yuck!). :)

Anyway, I hope this helps. Thanks for the great library!
Krys

pyzmq doesn't compile against latest zeromq

Compiling pyzmq with the latest zeromq gives me the following error:
zmq/_zmq.c: In function ‘init_zmq’:
zmq/_zmq.c:11185: error: ‘EMTHREAD’ undeclared (first use in this function)

Commit 05d908492dc382941fc633ad7082b5bd86e84e67 removes the definition of the EMTHREAD macro.

Python 3.x support - Feature

Generally use the python built into blender (3.1) and would like to be able to use pyzmq directly from it for a render farm solution. I know there was some work done a while ago on a separate fork. What would be the "gotchas" to upgrading to 3x?

Patch to fix compilation line on Windows

The current setup.py attemps to use gcc specific flags on Windows.

The patch below fix that.

--- setup.py.orig       2010-11-15 22:35:14.000000000 +0100
+++ setup.py    2011-02-16 22:35:59.640625000 +0100
@@ -49,7 +49,7 @@
 if get_default_compiler() in ('unix', 'mingw32'):
     ignore_common_warnings=True
 else:
-    ignore_common_warnings=True
+    ignore_common_warnings=False

 release = False # flag for whether to include *.c in package_data

zmq.select returns empty array instead of socket reference sometimes

The example provided below is a simple representation of my problem. It should wait 4 seconds for the other side to reply, then exit (because inputready is then []). The timeout works fine, but in case the other side connects, the content of inputready very often (not always) still is [], instead of something like [<zmq.core.socket.Socket object at 0xb73ffc0c>]. So in context it appears as if the timeout immediatly is reached when the client connects (actual timeout far from being reached).
If you leave out the timeout ( zmq.select([0, s], [], [], 4) -> zmq.select([0, s], [], []) ) the return value is always correct.

server.py:

 #!/usr/bin/python
 import zmq, time
 c = zmq.Context()
 s = c.socket(zmq.REP)
 s.bind('tcp://*:1234')
 inputready, outputready, exceptready = zmq.select([0, s], [], [], 4)
 if inputready == []:
     print("quit by timeout")
 else:
     for i in inputready:
         if i == 0:
             print("quit by keypress")
         if i == s:
             print(s.recv())
             s.send("pong")
 time.sleep(1)

client.py:

 #!/usr/bin/python
 import zmq
 c = zmq.Context()
 s = c.socket(zmq.REQ)
 s.connect('tcp://*:1234')
 s.send("ping")
 inputready, outputready, exceptready = zmq.select([s, 0], [], [], 4)
 if inputready == []:
     print("quit by timeout")
 else:
     for i in inputready:
         if i == 0:
             print("quit by keypress")
         if i == s:
             print(s.recv())

Deadlock between Python GC/zmq.Socket.close() and zmq_free_fn () both acquiring GIL

As discussed in this thread on the ØMQ mailing list:http://lists.zeromq.org/pipermail/zeromq-dev/2010-September/005824.html

There is an issue with PyZMQ use of zmq_free_fn() when zero-copy is in use. zmq_free_fn() is attempting to acquire the GIL when called from the ØMQ I/O thread; this will lead to deadlock if the message deallocation is happening due to zmq.Socket.close() being called in the main thread.

It would seem that the best solution would be to use the Py_AddPendingCall() function added in Python 2.7 as suggested by Jon Dyte on the mailing list, however that would still lead to deadlock for users using older versions of Python who wish to use zero-copy.

Build on Linux

sudo easy_install pyzmq
Searching for pyzmq
Reading http://pypi.python.org/simple/pyzmq/
Reading http://github.com/zeromq/pyzmq
Reading http://github.com/zeromq/pyzmq/downloads
Best match: pyzmq 2.0.7
Downloading http://github.com/downloads/zeromq/pyzmq/pyzmq-2.0.7.zip
Processing pyzmq-2.0.7.zip
Running pyzmq-2.0.7/setup.py -q bdist_egg --dist-dir /tmp/easy_install-KO2F57/pyzmq-2.0.7/egg-dist-tmp-QzSWP7
zmq/_zmq.c: In function ‘init_zmq’:
zmq/_zmq.c:10583: error: ‘EMTHREAD’ undeclared (first use in this function)
zmq/_zmq.c:10583: error: (Each undeclared identifier is reported only once
zmq/_zmq.c:10583: error: for each function it appears in.)
error: Setup script exited with error: command 'gcc' failed with exit status 1

or

python setup.py build_ext --rpath=/opt/zeromq-2.0.8/lib/ --inplace
running build_ext
building 'zmq._zmq' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c zmq/_zmq.c -o build/temp.linux-x86_64-2.6/zmq/_zmq.o
zmq/_zmq.c: In function ‘init_zmq’:
zmq/_zmq.c:11185: error: ‘EMTHREAD’ undeclared (first use in this function)
zmq/_zmq.c:11185: error: (Each undeclared identifier is reported only once
zmq/_zmq.c:11185: error: for each function it appears in.)
error: command 'gcc' failed with exit status 1

Zeromq install 2.0.7, 2.0.8, 2.0.9 from http://github.com/zeromq/zeromq2
OS: Ubuntu 9.10

nosetests fails with 2.0.10

Here are the failures of 2.0.10:

Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/nose/loader.py", line 382, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.6/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.6/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/tom/rpmbuild/BUILD/pyzmq-2.0.10/zmq/core/init.py", line 32, in
all.extend(submod.all)
AttributeError: 'builtin_function_or_method' object has no attribute 'all'

ERROR: Failure: NameError (name 'monitoredqueuedevice' is not defined)

Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/nose/loader.py", line 382, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.6/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.6/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/tom/rpmbuild/BUILD/pyzmq-2.0.10/zmq/devices/init.py", line 34, in
for submod in (basedevice, monitoredqueue, monitoredqueuedevice):
NameError: name 'monitoredqueuedevice' is not defined


Ran 55 tests in 8.240s

I don't see, why the first one is failing, but the second is now fixed in:
https://github.com/tomspur/pyzmq/tree/ready_failed_tests

ImportError: cannot import name initthreads

After installation python import zmq results in a traceback:

Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import zmq
Traceback (most recent call last):
  File "", line 1, in 
  File "zmq\__init__.py", line 26, in 
    from zmq.utils import initthreads # initialize threads
ImportError: cannot import name initthreads

I am using:
* zeromq-2.1.1
* pymzq-2.1.1
* Visual Studio 2008
* Windows XP SP3
Compilation was successful. Then I did the usual

setup.py build
setup.py install

Warnings and errors when building with Cython 0.13

There are several deprecation warnings, and one error message, when you try to compile _zmq.pyx using Cython 0.13:

cythoning zmq/_zmq.pyx to zmq/_zmq.c
warning: /Users/dcreager/git/pyzmq/zmq/_zmq.pyx:27:0: 'stdlib' is deprecated, use 'libc.stdlib'
warning: /Users/dcreager/git/pyzmq/zmq/_zmq.pyx:28:0: 'python_string' is deprecated, use 'cpython'
warning: /Users/dcreager/git/pyzmq/zmq/_zmq.pyx:31:0: 'python_ref' is deprecated, use 'cpython'

Error converting Pyrex file to C:
------------------------------------------------------------
...

    #-------------------------------------------------------------------------
    # Sending and receiving messages
    #-------------------------------------------------------------------------

    def send(self, object data, int flags=0, bool copy=True):
                                            ^
------------------------------------------------------------

/Users/dcreager/git/pyzmq/zmq/_zmq.pyx:641:45: 'bool' is not a type identifier

Test fails

The test suite fails. However, other programs using pyzmq are working OK.

sustrik@turist ~/pyzmq $ python setup.py test
running test
Traceback (most recent call last):
  File "setup.py", line 144, in 
    'Topic :: System :: Networking'
  File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "setup.py", line 59, in run
    tests = TestLoader().loadTestsFromNames(testfiles)
  File "/usr/lib/python2.6/unittest.py", line 613, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.6/unittest.py", line 576, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "/home/sustrik/pyzmq/zmq/__init__.py", line 26, in 
    from zmq import _zmq
ImportError: cannot import name _zmq

intermittent malloc error when checking for ENOTSUP

Hi,

When I'm running the test suite for the eventlet/zeromq stuff I occasionally get this is my test output:

$ EVENTLET_HUB=zeromq nosetests -v tests/zmq_test.py
test_different_context_in_different_thread (tests.zmq_test.TestThreadedContextAccess) ... ok
test_threadlocal_context (tests.zmq_test.TestThreadedContextAccess) ... ok
test_change_subscription (tests.zmq_test.TestUpstreamDownStream) ... ok
test_close_socket_raises_enotsup (tests.zmq_test.TestUpstreamDownStream) ... python(76333,0x102806000) malloc: *** error for object 0x10155aad0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap

This probably happens about once in 15 test runs or so.

This is the test case:

def test_close_socket_raises_enotsup(self):
    req, rep, port = self.create_bound_pair(zmq.PAIR, zmq.PAIR)
    rep.close()
    req.close()
    self.assertRaisesErrno(zmq.ENOTSUP, rep.recv)
    self.assertRaisesErrno(zmq.ENOTSUP, req.send, 'test')

You can see the full code here:
https://bitbucket.org/boothead/eventlet/src/tip/tests/zmq_test.py

I'm not exactly what you'd call a c or cython expert but if you could give me some pointers on how to provide more info I will certainly try.

Thanks,
Ben

Slow subscribers buffer until there is no more memory

I tried this on release and dev with the same effect. If I publish a lot of data, set the pub/sub's HWM to 1, and add a sleep after the sub's recv the memory usage gets out of control. What I want to happen is that the pub just drops messages that the sub can't process, but instead the sub is buffering. How can I set the sub's buffer size as I don't think it respect the HWM?

Fixes for small problems on Win64

I build pyzmq on Windows7 64bit with VC9.
I tried some examples. Examples using eventloop did not work.

Luckily I was able to fix the errors:

Problem 1:
The following error occured:
Traceback (most recent call last):
File "echo.py", line 27, in
loop.start()
File "c:\Python27\lib\site-packages\zmq\eventloop\ioloop.py", line 255, in start
e = sys.exc_info[1]
TypeError: 'builtin_function_or_method' object is not subscriptable

=> Removing [1] from e = sys.exc_info[1] fixed this problem.

After this fix I got the following error:
Traceback (most recent call last):
File "echo.py", line 27, in
loop.start()
File "c:\Python27\lib\site-packages\zmq\eventloop\ioloop.py", line 244, in start
event_pairs = self._impl.poll(poll_timeout)
File "poll.pyx", line 169, in zmq.core.poll.Poller.poll (zmq\core\poll.c:1980)
File "poll.pyx", line 83, in zmq.core.poll._poll (zmq\core\poll.c:1250)
TypeError: Socket must be a 0MQ socket, an integer fd or have a fileno() method: 140L

In file: poll.pyx I changed line 67 from:
elif isinstance(s, int):
to:
elif isinstance(s, int) or isinstance(s, long):

After this, the examples are Working on windows 64bit.

I'm no expert with git, so I have no branch where you can pull from.
Furthermore I came in touch with Cython the first time and I just "guesed" to make it work. So the bug fixes are probably not optimal. The first fix may break the linux/unix version(?!). The second fix can probably be better implemented. Is there a "size_t" in Cython?

Regards, Ralf

invalid ELF header

Hello, what could be the cause of this error? How can i fix it?

I compiled and installed zeromq on ubuntu 10.04 without any errors.

When i try to execute the python test, it results in this error:

sean@teststation:~/zeromq/pyzmq-2.0.7$ python setup.py test
running test
Traceback (most recent call last):
File "setup.py", line 144, in
'Topic :: System :: Networking'
File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "setup.py", line 59, in run
tests = TestLoader().loadTestsFromNames(testfiles)
File "/usr/lib/python2.6/unittest.py", line 613, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python2.6/unittest.py", line 576, in loadTestsFromName
module = import('.'.join(parts_copy))
File "/home/jerome/zeromq/pyzmq-2.0.7/zmq/init.py", line 26, in
from zmq import _zmq
ImportError: /home/sean/zeromq/pyzmq-2.0.7/zmq/_zmq.so: invalid ELF header

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.