Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions ipykernel/datapub.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# Distributed under the terms of the Modified BSD License.

from traitlets.config import Configurable
from ipykernel.inprocess.socket import SocketABC
from traitlets import Instance, Dict, CBytes
from traitlets import Instance, Dict, CBytes, Any
from ipykernel.jsonutil import json_clean
from ipykernel.serialize import serialize_object
from jupyter_client.session import Session, extract_header
Expand All @@ -16,7 +15,7 @@ class ZMQDataPublisher(Configurable):

topic = topic = CBytes(b'datapub')
session = Instance(Session, allow_none=True)
pub_socket = Instance(SocketABC, allow_none=True)
pub_socket = Any(allow_none=True)
parent_header = Dict({})

def set_parent(self, parent):
Expand Down
5 changes: 2 additions & 3 deletions ipykernel/displayhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
import sys

from IPython.core.displayhook import DisplayHook
from ipykernel.inprocess.socket import SocketABC
from ipykernel.jsonutil import encode_images
from ipython_genutils.py3compat import builtin_mod
from traitlets import Instance, Dict
from traitlets import Instance, Dict, Any
from jupyter_client.session import extract_header, Session

class ZMQDisplayHook(object):
Expand Down Expand Up @@ -43,7 +42,7 @@ class ZMQShellDisplayHook(DisplayHook):
topic=None

session = Instance(Session, allow_none=True)
pub_socket = Instance(SocketABC, allow_none=True)
pub_socket = Any(allow_none=True)
parent_header = Dict({})

def set_parent(self, parent):
Expand Down
24 changes: 9 additions & 15 deletions ipykernel/inprocess/socket.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
""" 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
#-----------------------------------------------------------------------------
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

# Standard library imports.
import abc
import warnings
try:
from queue import Queue # Py 3
except ImportError:
from Queue import Queue # Py 2

# System library imports.
import zmq

# Local imports.
from traitlets import HasTraits, Instance, Int
from ipython_genutils.py3compat import with_metaclass

Expand All @@ -30,15 +20,19 @@
#-----------------------------------------------------------------------------

class SocketABC(with_metaclass(abc.ABCMeta, object)):

@abc.abstractmethod
def recv_multipart(self, flags=0, copy=True, track=False):
raise NotImplementedError

@abc.abstractmethod
def send_multipart(self, msg_parts, flags=0, copy=True, track=False):
raise NotImplementedError

SocketABC.register(zmq.Socket)

@classmethod
def register(cls, other_cls):
warnings.warn("SocketABC is deprecated.", DeprecationWarning)
abc.ABCMeta.register(cls, other_cls)

#-----------------------------------------------------------------------------
# Dummy socket class
Expand Down
3 changes: 1 addition & 2 deletions ipykernel/zmqshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from IPython.core import payloadpage
from IPython.core.usage import default_gui_banner
from IPython.display import display, Javascript
from ipykernel.inprocess.socket import SocketABC
from ipykernel import (
get_connection_file, get_connection_info, connect_qtconsole
)
Expand All @@ -58,7 +57,7 @@ class ZMQDisplayPublisher(DisplayPublisher):
"""A display publisher that publishes data using a ZeroMQ PUB socket."""

session = Instance(Session, allow_none=True)
pub_socket = Instance(SocketABC, allow_none=True)
pub_socket = Any(allow_none=True)
parent_header = Dict({})
topic = CBytes(b'display_data')

Expand Down