diff --git a/IPython/extensions/parallelmagic.py b/IPython/extensions/parallelmagic.py index d4b8af8..b108254 100755 --- a/IPython/extensions/parallelmagic.py +++ b/IPython/extensions/parallelmagic.py @@ -159,12 +159,24 @@ class ParalleMagic(Plugin): self.autopx = False print "%autopx disabled" - def pxrun_source(self, ipself, source, filename="", symbol="single"): - """A parallel replacement for InteractiveShell.run_source.""" + def pxrun_source(self, ipself, source, filename=None, + symbol='single', post_execute=True): + # We need to ensure that the source is unicode from here on. + if type(source)==str: + usource = source.decode(ipself.stdin_encoding) + else: + usource = source + + if 0: # dbg + print 'Source:', repr(source) # dbg + print 'USource:', repr(usource) # dbg + print 'type:', type(source) # dbg + print 'encoding', ipself.stdin_encoding # dbg + try: - code = ipself.compile(source, filename, symbol) - except (OverflowError, SyntaxError, ValueError): + code = ipself.compile(usource, symbol, ipself.execution_count) + except (OverflowError, SyntaxError, ValueError, TypeError, MemoryError): # Case 1 ipself.showsyntaxerror(filename) return None @@ -197,6 +209,6 @@ def load_ipython_extension(ip): global _loaded if not _loaded: plugin = ParalleMagic(shell=ip, config=ip.config) - ip.plugin_manager.register_plugin('parallel_magic', plugin) + ip.plugin_manager.register_plugin('parallelmagic', plugin) _loaded = True diff --git a/IPython/kernel/client.py b/IPython/kernel/client.py index 13de59b..3178a0b 100644 --- a/IPython/kernel/client.py +++ b/IPython/kernel/client.py @@ -44,8 +44,8 @@ warnings.filterwarnings('ignore', 'the sha module is deprecated', import sys +import twisted from twisted.internet import reactor -from twisted.internet.error import PotentialZombieWarning from twisted.python import log from IPython.kernel.clientconnector import ClientConnector, Cluster @@ -54,7 +54,6 @@ from IPython.kernel.twistedutil import blockingCallFromThread # These enable various things from IPython.kernel import codeutil -# import IPython.kernel.magic # Other things that the user will need from IPython.kernel.task import MapTask, StringTask @@ -64,7 +63,11 @@ from IPython.kernel.error import CompositeError # Code #------------------------------------------------------------------------------- -warnings.simplefilter('ignore', PotentialZombieWarning) +# PotentialZombieWarning is deprecated from Twisted 10.0.0 and above and +# using the filter on > 10.0.0 creates a warning itself. +if twisted.version.major < 10: + from twisted.internet.error import PotentialZombieWarning + warnings.simplefilter('ignore', PotentialZombieWarning) _client_tub = ClientConnector() @@ -77,6 +80,18 @@ TaskClient = get_task_client # class below. But, it does work for now. log.startLogging(sys.stdout, setStdout=0) +def _result_list_printer(obj, p, cycle): + if cycle: + return p.text('ResultList(...)') + return p.text(repr(obj)) + +# ResultList is a list subclass and will use the default pretty printer. +# This overrides that to use the __repr__ of ResultList. +ip = get_ipython() +ip.displayhook.default_formatter.for_type_by_name( + 'IPython.kernel.multiengineclient', 'ResultList', _result_list_printer +) + # Now we start the reactor in a thread rit = ReactorInThread() rit.setDaemon(True) diff --git a/IPython/kernel/multiengineclient.py b/IPython/kernel/multiengineclient.py index 2cda3b4..e244690 100644 --- a/IPython/kernel/multiengineclient.py +++ b/IPython/kernel/multiengineclient.py @@ -272,7 +272,7 @@ class InteractiveMultiEngineClient(object): except NameError: print "The IPython parallel magics (%result, %px, %autopx) only work within IPython." else: - pmagic = ip.plugin_manager.get_plugin('parallel_magic') + pmagic = ip.plugin_manager.get_plugin('parallelmagic') if pmagic is not None: pmagic.active_multiengine_client = self else: