File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -108,14 +108,17 @@ def start(self):
108
108
self .log .debug ("jupyter run: executing `%s`" % filename )
109
109
with open (filename ) as fp :
110
110
cell = fp .read ()
111
- self .run_cell (cell )
111
+ return_code = self .run_cell (cell )
112
+ if return_code :
113
+ raise Exception ("jupyter-run error running '%s'" % filename )
112
114
113
115
def run_cell (self , cell ):
114
116
"""
115
117
Run a cell on a KernelClient
116
118
Any output from the cell will be displayed.
117
119
"""
118
120
msg_id = self .kernel_client .execute (cell )
121
+ return_code = 0
119
122
while True :
120
123
try :
121
124
msg = self .kernel_client .get_iopub_msg (timeout = OUTPUT_TIMEOUT )
@@ -133,13 +136,18 @@ def run_cell(self, cell):
133
136
elif msg_type == 'stream' :
134
137
stream = getattr (sys , content ['name' ])
135
138
stream .write (content ['text' ])
139
+ # TODO: remove this when all kernels use error msg_type:
140
+ if content ['name' ] == "stderr" :
141
+ return_code = 1
136
142
elif msg_type in ('display_data' , 'execute_result' , 'error' ):
137
143
if msg_type == 'error' :
138
144
print ('\n ' .join (content ['traceback' ]), file = sys .stderr )
145
+ return_code = 1
139
146
else :
140
147
sys .stdout .write (content ['data' ].get ('text/plain' , '' ))
141
148
else :
142
149
pass
150
+ return return_code
143
151
144
152
main = launch_new_instance = RunApp .launch_instance
145
153
You can’t perform that action at this time.
0 commit comments