[zeromq-dev] zsock test hangs in pyczmq

Michel Pelletier pelletier.michel at gmail.com
Fri Jun 13 20:14:47 CEST 2014


On Fri, Jun 13, 2014 at 11:08 AM, Pieter Hintjens <ph at imatix.com> wrote:

> On Fri, Jun 13, 2014 at 7:55 PM, Michel Pelletier
> <pelletier.michel at gmail.com> wrote:
>
> > Some gdb adventures shows I was calling zsock_new with filename and
> line_nbr
> > args defaulting to NULL and 0 out of sheer laziness.
>
> That should actually work... it's usually what you'd do in release
> mode with all socket tracking switched off.
>

Yeah that's what I was thinking when I wrote it.  Python can't know how
czmq was compiled with ZSOCK_NOCHECK unless I expose it and that sounded
ugly to me, so instead I have:

@cdef('zsock_t * zsock_new_ (int type, const char *filename, size_t
line_nbr);')
def new(type, filename=None, line_nbr=None):
    if filename is None:
        frame = inspect.stack()[1][0]
        info = inspect.getframeinfo(frame)
        filename = info.filename
        line_nbr = info.lineno
    return ffi.gc(C.zsock_new_(type, filename, line_nbr), destroy)


Which sidesteps the issue by calling zsock_new_ directly with file and line
information from the frame's caller.  I don't think __FILE__ and __LINE__
would be useful to a pyczmq user, as it would end up referencing a
generated C file internal to CFFI.

-Michel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140613/ae402184/attachment.htm>


More information about the zeromq-dev mailing list