-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PyZMQ API improvements #172
Conversation
Message kept as backwards-compatible alias
Setting `ctx.linger = 5` results in sockets subsequently created by ctx having `LINGER=5`.
removes on_err / errback from ZMQStream, which can never be triggered POLLERR is exclusively for *non-zmq* FDs used with zmq_poll, and can never occur with a zmq socket according to `man zmq_poll`.
These methods add the stream to the arguments received by callbacks.
Howdy! Is it possible to rename the the Cheers |
I guess there's really no need to deprecate the old way, as they are different methods. See #166 for discussion of the new names. I'm not particularly happy with any name we've found yet (including on_recv_stream), so further recommendations are welcome. |
old on_recv/on_send no longer marked as deprecated. |
Hi! Cool, thanks. Cheers |
Comments:
|
I like being able to set socket options in the context. On the Frame/Message renaming. I think of Framing as being a lower-level construct (down towards the wire protocol) than a Message (which is the application level construct). I think the _best_way of distinguishing messages and multipart messages is the following terminology:
But we should probably follow what other language bindings and the core libs are doing. |
This is simply inaccurate - Message Group would suggest that it is multiple messages somehow associated, rather than a single message with multiple segments. A Message is a single zeromq communication, which may have one or more parts. That's why it's confusing that pyzmq's Message class does not reflect a message, but a part of a message. It is already the convention of other bindings and the Guide that these individual message parts are referred to as Frames. |
I don't think it is entirely inaccurate - but I am definitely not proposing we adopt the Message/Message Group terminology and I definitely don't feel strongly about this - let's pretend I didn't bring that up... If other bindings and the Guide are referring to them as Frames, we should definitely follow that. I do think we should leave Message there like you have done for backwards compat though. |
The concern about Frame you brought up regarding low-level terminology is valid, and has been brought up elsewhere. I started a discussion on zeromq-dev about this sort of naming convention in bindings, but it wandered off track without much useful information. The only point that does seem well established is that ZeroMQ has multipart messages (i.e. Message refers to the collection), and it doesn't make sense to call the parts of a multipart-message 'messages' themselves. Various names have been proposed by folks who don't like Frame (MessagePart, MessageFragment, etc.), but the only name actually in use anywhere is Frame (aka ZFrame, depending). |
I was following your thread until it drifted off topic. Let's just go with Frame (keeping Message for backwards compat.). |
Okay, sounds good. I certainly don't want to break any existing APIs with these changes, only add new ones (even for those meant as replacements). I'm using the IPython test suite to confirm backwards compatibility, as it's the heaviest user of the zero-copy and ZMQStream interfaces I know of. On the Context default options, there are two questions:
|
On (1) I don't have a strong feeling. Seems like the ctx.sockops dict provides a small amount of encapsulation that is nice, but the API is not quite as simple as the attribute-only. The attribute and method approaches more closely mirror the API of Socket itself, which is most consistent. In the end, I would probably pick either the attribute or method API - which ever of the two is most commonly used by Socket users. For me, I would probably use the attribute style. On (2), I am tempted to silently ignore the error, as there are some options that don't apply globally. While I am a bit hesitant to silently ignore errors, in this case, I think it is needed for this API to be useful. |
|
This part looks good, what did you decide on the Context socket options API? |
Another proposed change, with an eye towards cross-language consistency:
|
I think this is a good idea as well. |
I went with your suggestion on the Context - attributes only, errors when assigning to new sockets silently ignored (assumes things like SUBSCRIBE on non-SUB). |
`_unicode` kept as alias
OK great, I think this PR is getting close to being merge ready - once On Thu, Feb 9, 2012 at 12:40 PM, Min RK
Brian E. Granger |
Sure - I'll do a pass on the docs before I merge. |
Frame.more is bool, as opposed to flags, which was a bitmask Frame.flags solves a problem that doesn't exist, because there is only one flag at this point.
which used copy=False by default. It doesn't make sense to use different defaults than Socket.send, and non-copying sends can cause problems on shutdown without manually terminating the context in Python 3. ref: zeromq#173
Further small changes:
One last thing I am considering before finishing this up: Full removal of the |
I think using |
Okay, changes made, and docs updated. |
PyZMQ API improvements * on_recv_stream * scrub mistaken use of POLLERR * scrub unused prefix * ctx.sockopts * get_includes() fixes * Message -> Frame * _unicode -> _string closes #178
Some new APIs and deprecations of old ones that made no sense.
Deprecations
New Features
ctx.linger = 0
to set the initial LINGER of all subsequently created sockets, and the same with all sockopts.ZMQStream.on_recv_stream/on_send_send
callbacks, which get the stream as the first argument, in addition to those that were previously passed. Makes it easier to use a single function as the callback for multiple sockets.Changes
zmq.Message
renamed tozmq.Frame
, to better match high-level binding naming conventions. zmq.Message name remains for backwards compatibility.Cleanup
#!
lines from module files that are not scripts