Warning
This documentation is for an old version of IPython. You can find docs for newer versions here.
Module: kernel.threaded¶
Defines a KernelClient that provides thread-safe sockets with async callbacks on message replies.
3 Classes¶
-
class
IPython.kernel.threaded.ThreadedZMQSocketChannel(socket, session, loop)¶ Bases:
objectA ZMQ socket invoking a callback in the ioloop
-
__init__(socket, session, loop)¶ Create a channel.
Parameters: socket :
zmq.SocketThe ZMQ socket to use.
session :
session.SessionThe session to use.
loop
A pyzmq ioloop to connect the socket to using a ZMQStream
-
call_handlers(msg)¶ This method is called in the ioloop thread when a message arrives.
Subclasses should override this method to handle incoming messages. It is important to remember that this method is called in the thread so that some logic must be done to ensure that the application level handlers are called in the application thread.
-
flush(timeout=1.0)¶ Immediately processes all pending messages on this channel.
This is only used for the IOPub channel.
Callers should use this method to ensure that
call_handlers()has been called for all messages that have been received on the 0MQ SUB socket of this channel.This method is thread safe.
Parameters: timeout : float, optional
The maximum amount of time to spend flushing, in seconds. The default is one second.
-
process_events()¶ Subclasses should override this with a method processing any pending GUI events.
-
send(msg)¶ Queue a message to be sent from the IOLoop’s thread.
Parameters: msg : message to send
This is threadsafe, as it uses IOLoop.add_callback to give the loop’s
thread control of the action.
-
-
class
IPython.kernel.threaded.IOLoopThread(loop)¶ Bases:
threading.ThreadRun a pyzmq ioloop in a thread to send and receive messages
-
__init__(loop)¶
-
run()¶ Run my loop, ignoring EINTR events in the poller
-
-
class
IPython.kernel.threaded.ThreadedKernelClient(**kwargs)¶ Bases:
IPython.kernel.client.KernelClientA KernelClient that provides thread-safe sockets with async callbacks on message replies.
