Hi all -- I'm back to playing around with pyczmq for secure messaging. I'm perfectly happy with the pyzmq interface. In fact, I could happily stick with 0MQ 3.2.x, and ignore CZMQ (and pyczmq) entirely, except for the need for authentication and encryption.
A few weeks ago, I successfully translated the example "ironhouse" code from Pieter's blog (http://hintjens.com/blog:49) to Python using pyczmq. Now, as an experiment, I'm trying to switch that over to using *mostly* plain pyzmq (context, sockets, messages -- all the stuff that already works great with 0MQ 3.2), depending on pyczmq only for zcert and zauth. And I'm stumped. First attempt: back on Jan 17, Michel Pelletier said: > pyczmq exposes both zctx_shadow_zmq_ctx to make a czmq context out of > a zmq one but that doesn't seem to be true. There is no wrapper for zctx_shadow_zmq_ctx() in pyczmq/zctx.py. So I tried adding one: --- a/pyczmq/zctx.py +++ b/pyczmq/zctx.py @@ -47,6 +50,11 @@ def new(): return ffi.gc(C.zctx_new(), destroy) +@cdef('zctx_t * zctx_shadow_zmq_ctx (void *zmqctx);') +def shadow_zmq_ctx(zmqctx): + return C.zctx_shadow_zmq_ctx(zmqctx) + + @cdef('void zctx_set_iothreads (zctx_t *self, int iothreads);') def set_iothreads(ctx, iothreads): """ But that doesn't work: $ cat shadow-ctx.py import zmq from pyczmq import zctx ctx1 = zmq.Context() ctx2 = zctx.shadow_zmq_ctx(ctx1) $ python shadow-ctx.py Traceback (most recent call last): File "shadow-ctx.py", line 5, in <module> ctx2 = zctx.shadow_zmq_ctx(ctx1) File "/data/src/pyczmq/pyczmq/_cffi.py", line 21, in inner_f val = f(*args) File "/data/src/pyczmq/pyczmq/zctx.py", line 55, in shadow_zmq_ctx return C.zctx_shadow_zmq_ctx(zmqctx) TypeError: initializer for ctype 'void *' must be a cdata pointer, not Context Arghghh. Impedance mismatch. Any idea how to make that wrapper work? Second attempt: also back on Jan 17, Michel continued: > ... and zctx_underlying for the inverse. OK, I figured, If I can't turn a pyzmq-created Context into something that pyczmq likes, maybe I can go the other way. $ cat underlying-ctx.py import zmq from pyczmq import zctx ctx1 = zctx.new() ctx2 = zctx.underlying(ctx1) print ctx1 print ctx2 $ python underlying-ctx.py <cdata 'zctx_t *' 0x13f47c0> None <<< ARGH! (not a pyzmq Context object) The problem is right in the docstring for zctx.underlying(): def underlying(ctx): """ Return low-level 0MQ context object, will be NULL before first socket is created. Use with care. """ Well, I'm stumped. Has anyone successfully used pyzmq and pyczmq in the same script? Care to show the code? Thanks -- Greg _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
