Skip to content
This repository

Don't die if stderr/stdout do not support set_parent() #2925 #2926

Merged
merged 1 commit into from about 1 year ago

2 participants

y-p Min RK
y-p

If the user redirects the streams to a file for example,
the kernel would raise an exception because file
objects do not have set_parent defined, unlike ipython's
OutStream.
This happens even if the user does this in a spawned thread.

closes #2925

Min RK
Owner

set_parent is also called on L576-577

y-p Don't die if stderr/stdout do not support set_parent() #2925
If the user redirects the streams to a file for example,
the kernel would raise an exception because file
objects do not have set_parent defined, unlike ipython's
OutStream.
This happens even if the user does this in a spawned thread.
9deb416
y-p

thank you, fixed.

Min RK
Owner

simple enough, merging. Thanks!

Min RK minrk merged commit 465f43c into from February 12, 2013
Min RK minrk closed this February 12, 2013
y-p

45 minutes from hitting a bug to upstream fixed. This is why I love open-source.

Min RK
Owner

it's nice when it works out.

Min RK minrk referenced this pull request from a commit March 04, 2013
Min RK Backport PR #2926: Don't die if stderr/stdout do not support set_pare…
…nt() #2925

If the user redirects the streams to a file for example,
the kernel would raise an exception because file
objects do not have set_parent defined, unlike ipython's
OutStream.
This happens even if the user does this in a spawned thread.

closes #2925
01f1179
Min RK minrk referenced this pull request from a commit March 04, 2013
Min RK Backport PR #2926: Don't die if stderr/stdout do not support set_pare…
…nt() #2925

If the user redirects the streams to a file for example,
the kernel would raise an exception because file
objects do not have set_parent defined, unlike ipython's
OutStream.
This happens even if the user does this in a spawned thread.

closes #2925
f85e1f8
y-p y-p deleted the branch January 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 13, 2013
y-p Don't die if stderr/stdout do not support set_parent() #2925
If the user redirects the streams to a file for example,
the kernel would raise an exception because file
objects do not have set_parent defined, unlike ipython's
OutStream.
This happens even if the user does this in a spawned thread.
9deb416
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 17 additions and 5 deletions. Show diff stats Hide diff stats

  1. 22  IPython/kernel/zmq/ipkernel.py
22  IPython/kernel/zmq/ipkernel.py
@@ -364,8 +364,14 @@ def execute_request(self, stream, ident, parent):
364 364
         shell.displayhook.set_parent(parent)
365 365
         shell.display_pub.set_parent(parent)
366 366
         shell.data_pub.set_parent(parent)
367  
-        sys.stdout.set_parent(parent)
368  
-        sys.stderr.set_parent(parent)
  367
+        try:
  368
+            sys.stdout.set_parent(parent)
  369
+        except AttributeError:
  370
+            pass
  371
+        try:
  372
+            sys.stderr.set_parent(parent)
  373
+        except AttributeError:
  374
+            pass
369 375
 
370 376
         # Re-broadcast our input for the benefit of listening clients, and
371 377
         # start computing output
@@ -567,14 +573,20 @@ def apply_request(self, stream, ident, parent):
567 573
             return
568 574
 
569 575
         self._publish_status(u'busy', parent)
570  
-        
  576
+
571 577
         # Set the parent message of the display hook and out streams.
572 578
         shell = self.shell
573 579
         shell.displayhook.set_parent(parent)
574 580
         shell.display_pub.set_parent(parent)
575 581
         shell.data_pub.set_parent(parent)
576  
-        sys.stdout.set_parent(parent)
577  
-        sys.stderr.set_parent(parent)
  582
+        try:
  583
+            sys.stdout.set_parent(parent)
  584
+        except AttributeError:
  585
+            pass
  586
+        try:
  587
+            sys.stderr.set_parent(parent)
  588
+        except AttributeError:
  589
+            pass
578 590
 
579 591
         # pyin_msg = self.session.msg(u'pyin',{u'code':code}, parent=parent)
580 592
         # self.iopub_socket.send(pyin_msg)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.