Show More
@@ -261,6 +261,9 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
261 | deep_reload will still be available as dreload(). |
|
261 | deep_reload will still be available as dreload(). | |
262 | """ |
|
262 | """ | |
263 | ) |
|
263 | ) | |
|
264 | disable_failing_post_execute = CBool(False, config=True, | |||
|
265 | help="Don't call post-execute functions that have failed in the past.""" | |||
|
266 | ) | |||
264 | display_formatter = Instance(DisplayFormatter) |
|
267 | display_formatter = Instance(DisplayFormatter) | |
265 | displayhook_class = Type(DisplayHook) |
|
268 | displayhook_class = Type(DisplayHook) | |
266 | display_pub_class = Type(DisplayPublisher) |
|
269 | display_pub_class = Type(DisplayPublisher) | |
@@ -749,7 +752,7 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
749 | if not callable(func): |
|
752 | if not callable(func): | |
750 | raise ValueError('argument %s must be callable' % func) |
|
753 | raise ValueError('argument %s must be callable' % func) | |
751 | self._post_execute[func] = True |
|
754 | self._post_execute[func] = True | |
752 |
|
755 | |||
753 | #------------------------------------------------------------------------- |
|
756 | #------------------------------------------------------------------------- | |
754 | # Things related to the "main" module |
|
757 | # Things related to the "main" module | |
755 | #------------------------------------------------------------------------- |
|
758 | #------------------------------------------------------------------------- | |
@@ -2426,17 +2429,22 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
2426 |
|
2429 | |||
2427 | # Execute any registered post-execution functions. |
|
2430 | # Execute any registered post-execution functions. | |
2428 | for func, status in self._post_execute.iteritems(): |
|
2431 | for func, status in self._post_execute.iteritems(): | |
2429 | if not status: |
|
2432 | if self.disable_failing_post_execute and not status: | |
2430 | continue |
|
2433 | continue | |
2431 | try: |
|
2434 | try: | |
2432 | func() |
|
2435 | func() | |
2433 | except KeyboardInterrupt: |
|
2436 | except KeyboardInterrupt: | |
2434 | print >> io.stderr, "\nKeyboardInterrupt" |
|
2437 | print >> io.stderr, "\nKeyboardInterrupt" | |
2435 | except Exception: |
|
2438 | except Exception: | |
2436 | print >> io.stderr, "Disabling failed post-execution function: %s" % func |
|
2439 | # register as failing: | |
2437 | self.showtraceback() |
|
|||
2438 | # Deactivate failing function |
|
|||
2439 | self._post_execute[func] = False |
|
2440 | self._post_execute[func] = False | |
|
2441 | self.showtraceback() | |||
|
2442 | print >> io.stderr, '\n'.join([ | |||
|
2443 | "post-execution function %r produced an error." % func, | |||
|
2444 | "If this problem persists, you can disable failing post-exec functions with:", | |||
|
2445 | "", | |||
|
2446 | " get_ipython().disable_failing_post_execute = True" | |||
|
2447 | ]) | |||
2440 |
|
2448 | |||
2441 | if store_history: |
|
2449 | if store_history: | |
2442 | # Write output to the database. Does nothing unless |
|
2450 | # Write output to the database. Does nothing unless |
General Comments 0
You need to be logged in to leave comments.
Login now