##// END OF EJS Templates
Merge pull request #955 from minrk/websocket...
Merge pull request #955 from minrk/websocket Websocket fixes: 1. alert client on failed and lost web socket connections A long message is given if the connection fails within 1s, which assumes the connection did not succeed. Otherwise, it is a short 'connection closed unexpectedly'. This also means that clients are notified on server termination (for better or worse). 2. remove superfluous ws-hostname parameter from notebook This made the notebook server artificially and unnecessarily brittle against tunneling and explicit hostname resolution. Now, the ws_url is defined based on the Origin of the request for the url, so it always matches the http[s] url. This means that it will follow the same tunnel, and the hostname will be already resolved. Resolving the hostname twice makes no sense at all unless the websockets are going to a different server than the http requests. Implemented as a property, so it should still be easy to change for future cases where it might behave differently (e.g. websockets on a different host, or at a non-root url).

File last commit:

r4862:afbc4511
r5301:f6b3d8ff merge
Show More
display_trap.py
70 lines | 2.1 KiB | text/x-python | PythonLexer
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231 # encoding: utf-8
"""
A context manager for handling sys.displayhook.
Authors:
* Robert Kern
* Brian Granger
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008-2009 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
#-----------------------------------------------------------------------------
import sys
Brian Granger
First draft of refactored Component->Configurable.
r2731 from IPython.config.configurable import Configurable
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740 from IPython.utils.traitlets import Any
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231
#-----------------------------------------------------------------------------
# Classes and functions
#-----------------------------------------------------------------------------
Brian Granger
First draft of refactored Component->Configurable.
r2731 class DisplayTrap(Configurable):
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231 """Object to manage sys.displayhook.
This came from IPython.core.kernel.display_hook, but is simplified
(no callbacks or formatters) until more of the core is refactored.
"""
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740 hook = Any
def __init__(self, hook=None):
super(DisplayTrap, self).__init__(hook=hook, config=None)
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231 self.old_hook = None
Brian Granger
Massive refactoring of of the core....
r2245 # We define this to track if a single BuiltinTrap is nested.
# Only turn off the trap when the outermost call to __exit__ is made.
self._nested_level = 0
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231
def __enter__(self):
Brian Granger
Massive refactoring of of the core....
r2245 if self._nested_level == 0:
self.set()
self._nested_level += 1
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231 return self
def __exit__(self, type, value, traceback):
Brian Granger
Massive refactoring of of the core....
r2245 if self._nested_level == 1:
self.unset()
self._nested_level -= 1
Brian Granger
The pretty.py extension has been ported to the new extension API....
r2281 # Returning False will cause exceptions to propagate
return False
Brian Granger
sys.displayhook is now managed dynamically by display_trap.
r2231
def set(self):
"""Set the hook."""
if sys.displayhook is not self.hook:
self.old_hook = sys.displayhook
sys.displayhook = self.hook
def unset(self):
"""Unset the hook."""
sys.displayhook = self.old_hook