@@ -330,6 +330,10 @@ def result(self, line=''):
330
330
if self .last_result is None :
331
331
raise UsageError (NO_LAST_RESULT )
332
332
333
+ if args .save_name :
334
+ self .shell .user_ns [args .save_name ] = self .last_result
335
+ return
336
+
333
337
self .last_result .get ()
334
338
self .last_result .display_outputs (groupby = args .groupby )
335
339
@@ -402,37 +406,26 @@ def parallel_execute(
402
406
# wait for 'quick' results before showing progress
403
407
tic = time .perf_counter ()
404
408
deadline = tic + progress_after
405
- try :
406
- result .get (timeout = progress_after )
407
- remaining = max (deadline - time .perf_counter (), 0 )
408
- result .wait_for_output (timeout = remaining )
409
- except TimeoutError :
410
- pass
411
- except error .CompositeError as e :
412
- if stream_output :
413
- # already streamed, show an abbreviated result
414
- raise error .AlreadyDisplayedError (e ) from None
415
- else :
416
- raise
417
- else :
418
- finished_waiting = True
409
+ result .wait (timeout = progress_after )
410
+ remaining = max (deadline - time .perf_counter (), 0 )
411
+ result .wait_for_output (timeout = remaining )
412
+ finished_waiting = result .done ()
419
413
420
414
if not finished_waiting :
421
415
if progress_after >= 0 :
422
416
# not an immediate result, start interactive progress
423
417
result .wait_interactive ()
424
- result .wait_for_output ()
425
- try :
426
- result .get ()
427
- except error .CompositeError as e :
428
- if stream_output :
429
- # already streamed, show an abbreviated result
430
- raise error .AlreadyDisplayedError (e ) from None
431
- else :
432
- raise
418
+ result .wait_for_output (1 )
419
+
420
+ try :
421
+ result .get ()
422
+ except error .CompositeError as e :
423
+ if stream_output :
424
+ # already streamed, show an abbreviated result
425
+ raise error .AlreadyDisplayedError (e ) from None
426
+ else :
427
+ raise
433
428
# Skip redisplay if streaming output
434
- if not stream_output :
435
- result .display_outputs (groupby )
436
429
except KeyboardInterrupt :
437
430
if signal_on_interrupt is not None :
438
431
print (
@@ -444,6 +437,14 @@ def parallel_execute(
444
437
)
445
438
else :
446
439
raise
440
+ finally :
441
+ # always redisplay outputs if not streaming,
442
+ # on both success and error
443
+
444
+ if not stream_output :
445
+ # wait for at most 1 second for output to be complete
446
+ result .wait_for_output (1 )
447
+ result .display_outputs (groupby )
447
448
else :
448
449
# return AsyncResult only on non-blocking submission
449
450
return result
0 commit comments