Show More
@@ -495,7 +495,6 b' class Kernel(Configurable):' | |||||
495 | content = parent[u'content'] |
|
495 | content = parent[u'content'] | |
496 | bufs = parent[u'buffers'] |
|
496 | bufs = parent[u'buffers'] | |
497 | msg_id = parent['header']['msg_id'] |
|
497 | msg_id = parent['header']['msg_id'] | |
498 | # bound = parent['header'].get('bound', False) |
|
|||
499 | except: |
|
498 | except: | |
500 | self.log.error("Got bad msg: %s", parent, exc_info=True) |
|
499 | self.log.error("Got bad msg: %s", parent, exc_info=True) | |
501 | return |
|
500 | return | |
@@ -510,15 +509,11 b' class Kernel(Configurable):' | |||||
510 | sys.displayhook.set_parent(parent) |
|
509 | sys.displayhook.set_parent(parent) | |
511 | sys.stdout.set_parent(parent) |
|
510 | sys.stdout.set_parent(parent) | |
512 | sys.stderr.set_parent(parent) |
|
511 | sys.stderr.set_parent(parent) | |
513 | # exec "f(*args,**kwargs)" in self.user_ns, self.user_ns |
|
512 | working = self.shell.user_ns | |
514 | working = self.user_ns |
|
513 | ||
515 | # suffix = |
|
|||
516 | prefix = "_"+str(msg_id).replace("-","")+"_" |
|
514 | prefix = "_"+str(msg_id).replace("-","")+"_" | |
517 |
|
515 | |||
518 | f,args,kwargs = unpack_apply_message(bufs, working, copy=False) |
|
516 | f,args,kwargs = unpack_apply_message(bufs, working, copy=False) | |
519 | # if bound: |
|
|||
520 | # bound_ns = Namespace(working) |
|
|||
521 | # args = [bound_ns]+list(args) |
|
|||
522 |
|
517 | |||
523 | fname = getattr(f, '__name__', 'f') |
|
518 | fname = getattr(f, '__name__', 'f') | |
524 |
|
519 | |||
@@ -530,15 +525,13 b' class Kernel(Configurable):' | |||||
530 | ns = { fname : f, argname : args, kwargname : kwargs , resultname : None } |
|
525 | ns = { fname : f, argname : args, kwargname : kwargs , resultname : None } | |
531 | # print ns |
|
526 | # print ns | |
532 | working.update(ns) |
|
527 | working.update(ns) | |
533 | code = "%s=%s(*%s,**%s)"%(resultname, fname, argname, kwargname) |
|
528 | code = "%s = %s(*%s,**%s)" % (resultname, fname, argname, kwargname) | |
534 | try: |
|
529 | try: | |
535 | exec code in working,working |
|
530 | exec code in self.shell.user_global_ns, self.shell.user_ns | |
536 | result = working.get(resultname) |
|
531 | result = working.get(resultname) | |
537 | finally: |
|
532 | finally: | |
538 | for key in ns.iterkeys(): |
|
533 | for key in ns.iterkeys(): | |
539 | working.pop(key) |
|
534 | working.pop(key) | |
540 | # if bound: |
|
|||
541 | # working.update(bound_ns) |
|
|||
542 |
|
535 | |||
543 | packed_result,buf = serialize_object(result) |
|
536 | packed_result,buf = serialize_object(result) | |
544 | result_buf = [packed_result]+buf |
|
537 | result_buf = [packed_result]+buf | |
@@ -586,10 +579,9 b' class Kernel(Configurable):' | |||||
586 |
|
579 | |||
587 | def clear_request(self, stream, idents, parent): |
|
580 | def clear_request(self, stream, idents, parent): | |
588 | """Clear our namespace.""" |
|
581 | """Clear our namespace.""" | |
589 | self.user_ns = {} |
|
582 | self.shell.reset(False) | |
590 | msg = self.session.send(stream, 'clear_reply', ident=idents, parent=parent, |
|
583 | msg = self.session.send(stream, 'clear_reply', ident=idents, parent=parent, | |
591 | content = dict(status='ok')) |
|
584 | content = dict(status='ok')) | |
592 | self._initial_exec_lines() |
|
|||
593 |
|
585 | |||
594 |
|
586 | |||
595 | #--------------------------------------------------------------------------- |
|
587 | #--------------------------------------------------------------------------- | |
@@ -597,6 +589,14 b' class Kernel(Configurable):' | |||||
597 | #--------------------------------------------------------------------------- |
|
589 | #--------------------------------------------------------------------------- | |
598 |
|
590 | |||
599 |
|
591 | |||
|
592 | def _wrap_exception(self, method=None): | |||
|
593 | # import here, because _wrap_exception is only used in parallel, | |||
|
594 | # and parallel has higher min pyzmq version | |||
|
595 | from IPython.parallel.error import wrap_exception | |||
|
596 | e_info = dict(engine_uuid=self.ident, engine_id=self.int_id, method=method) | |||
|
597 | content = wrap_exception(e_info) | |||
|
598 | return content | |||
|
599 | ||||
600 | def _topic(self, topic): |
|
600 | def _topic(self, topic): | |
601 | """prefixed topic for IOPub messages""" |
|
601 | """prefixed topic for IOPub messages""" | |
602 | if self.int_id >= 0: |
|
602 | if self.int_id >= 0: |
General Comments 0
You need to be logged in to leave comments.
Login now