class_docstr: A utility class to register callbacks when a zmq socket sends and receives
  
  For use with zmq.eventloop.ioloop
  
  There are three main methods
  
  Methods:
  
  * **on_recv(callback, copy=True):**
      register a callback to be run every time the socket has something to receive
  * **on_send(callback):**
      register a callback to be run every time you call send
  * **send(self, msg, flags=0, copy=False, callback=None):**
      perform a send that will trigger the callback
      if callback is passed, on_send is also called.
      
      There are also send_multipart(), send_json(), send_pyobj()
  
  Three other methods for deactivating the callbacks:
  
  * **stop_on_recv():**
      turn off the recv callback
  * **stop_on_send():**
      turn off the send callback
  
  which simply call ``on_<evt>(None)``.
  
  The entire socket interface, excluding direct recv methods, is also
  provided, primarily through direct-linking the methods.
  e.g.
  
  >>> stream.bind is stream.socket.bind
  True
class_docstr_tok: ["A","utility","class","to","register","callbacks","when","a","zmq","socket","sends","and","receives","For","use","with","zmq.eventloop.ioloop","There","are","three","main","methods","Methods",":","*","*","*","on_recv","(","callback",",","copy=True",")",":","*","*","register","a","callback","to","be","run","every","time","the","socket","has","something","to","receive","*","*","*","on_send","(","callback",")",":","*","*","register","a","callback","to","be","run","every","time","you","call","send","*","*","*","send","(","self",",","msg",",","flags=0",",","copy=False",",","callback=None",")",":","*","*","perform","a","send","that","will","trigger","the","callback","if","callback","is","passed",",","on_send","is","also","called",".","There","are","also","send_multipart","(",")",",","send_json","(",")",",","send_pyobj","(",")","Three","other","methods","for","deactivating","the","callbacks",":","*","*","*","stop_on_recv","(",")",":","*","*","turn","off","the","recv","callback","*","*","*","stop_on_send","(",")",":","*","*","turn","off","the","send","callback","which","simply","call","``","on_","<","evt",">","(","None",")","``",".","The","entire","socket","interface",",","excluding","direct","recv","methods",",","is","also","provided",",","primarily","through","direct-linking","the","methods",".","e.g",".",">",">",">","stream.bind","is","stream.socket.bind","True"]
docstr: Register a callback to be called on each send
  
  There will be two arguments::
  
      callback(msg, status)
  
  * `msg` will be the list of sendable objects that was just sent
  * `status` will be the return result of socket.send_multipart(msg) -
    MessageTracker or None.
  
  Non-copying sends return a MessageTracker object whose
  `done` attribute will be True when the send is complete.
  This allows users to track when an object is safe to write to
  again.
  
  The second argument will always be None if copy=True
  on the send.
  
  Use on_send_stream(callback) to register a callback that will be passed
  this ZMQStream as the first argument, in addition to the other two.
  
  on_send(None) disables recv event polling.
  
  Parameters
  ----------
  
  callback : callable
      callback must take exactly two arguments, which will be
      the message being sent (always a list),
      and the return result of socket.send_multipart(msg) -
      MessageTracker or None.
      
      if callback is None, send callbacks are disabled.
docstr_tok: ["Register","a","callback","to","be","called","on","each","send","There","will","be","two","arguments",":",":","callback","(","msg",",","status",")","*","`","msg","`","will","be","the","list","of","sendable","objects","that","was","just","sent","*","`","status","`","will","be","the","return","result","of","socket.send_multipart","(","msg",")","-","MessageTracker","or","None",".","Non-copying","sends","return","a","MessageTracker","object","whose","`","done","`","attribute","will","be","True","when","the","send","is","complete",".","This","allows","users","to","track","when","an","object","is","safe","to","write","to","again",".","The","second","argument","will","always","be","None","if","copy=True","on","the","send",".","Use","on_send_stream","(","callback",")","to","register","a","callback","that","will","be","passed","this","ZMQStream","as","the","first","argument",",","in","addition","to","the","other","two",".","on_send","(","None",")","disables","recv","event","polling",".","Parameters","--","--","--","--","--","callback",":","callable","callback","must","take","exactly","two","arguments",",","which","will","be","the","message","being","sent","(","always","a","list",")",",","and","the","return","result","of","socket.send_multipart","(","msg",")","-","MessageTracker","or","None",".","if","callback","is","None",",","send","callbacks","are","disabled","."]
code: def on_send(self, callback):
      """Register a callback to be called on each send
  
      There will be two arguments::
  
          callback(msg, status)
  
      * `msg` will be the list of sendable objects that was just sent
      * `status` will be the return result of socket.send_multipart(msg) -
        MessageTracker or None.
  
      Non-copying sends return a MessageTracker object whose
      `done` attribute will be True when the send is complete.
      This allows users to track when an object is safe to write to
      again.
  
      The second argument will always be None if copy=True
      on the send.
  
      Use on_send_stream(callback) to register a callback that will be passed
      this ZMQStream as the first argument, in addition to the other two.
  
      on_send(None) disables recv event polling.
  
      Parameters
      ----------
  
      callback : callable
          callback must take exactly two arguments, which will be
          the message being sent (always a list),
          and the return result of socket.send_multipart(msg) -
          MessageTracker or None.
  
          if callback is None, send callbacks are disabled.
      """
  
      self._check_closed()
      assert callback is None or callable(callback)
      self._send_callback = stack_context_wrap(callback)
  
imports: from __future__ import with_statement
  import sys
  import warnings
  import zmq
  from zmq.utils import jsonapi
  from .ioloop import IOLoop, gen_log
  from zmq.utils.strtypes import basestring
label_desc: Use image node_id 8 for calling the ZMQStream obj's underlying member method code with example usage: obj.on_send(callback) without return types