forked from ipython/ipython
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
212 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,43 @@ | |||
""" Defines a dummy socket implementing (part of) the zmq.Socket interface. """ | |||
|
|||
#----------------------------------------------------------------------------- | |||
# Copyright (C) 2012 The IPython Development Team | |||
# | |||
# Distributed under the terms of the BSD License. The full license is in | |||
# the file COPYING, distributed as part of this software. | |||
#----------------------------------------------------------------------------- | |||
|
|||
#----------------------------------------------------------------------------- | |||
# Imports | |||
#----------------------------------------------------------------------------- | |||
|
|||
# Standard library imports. | |||
import Queue | |||
|
|||
# System library imports. | |||
import zmq | |||
|
|||
# Local imports. | |||
from IPython.utils.traitlets import HasTraits, Instance, Int | |||
|
|||
#----------------------------------------------------------------------------- | |||
# Dummy socket class | |||
#----------------------------------------------------------------------------- | |||
|
|||
class DummySocket(HasTraits): | |||
""" A dummy socket implementing (part of) the zmq.Socket interface. """ | |||
|
|||
queue = Instance(Queue.Queue, ()) | |||
message_sent = Int(0) # Should be an Event | |||
|
|||
#------------------------------------------------------------------------- | |||
# zmq.Socket interface | |||
#------------------------------------------------------------------------- | |||
|
|||
def recv_multipart(self, flags=0, copy=True, track=False): | |||
return self.queue.get_nowait() | |||
|
|||
def send_multipart(self, msg_parts, flags=0, copy=True, track=False): | |||
msg_parts = map(zmq.Message, msg_parts) | |||
self.queue.put_nowait(msg_parts) | |||
self.message_sent += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters