Skip to content
Snippets Groups Projects
Commit 2359b49c authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

MNT: Hook in idle module to allow errors to be propagated. Useful for testing.

parent 8d7d19a9
No related branches found
No related tags found
No related merge requests found
......@@ -196,6 +196,13 @@ _idleCallRate = 200
"""
_idleAllowErrors = False
"""Used for testing/debugging. If ``True``, and a function called on the idle
loop raises an error, that error will not be caught, and the idle loop will
stop.
"""
def idleReset():
"""Reset the internal :func:`idle` queue state.
......@@ -211,6 +218,7 @@ def idleReset():
global _idleQueueDict
global _idleTimer
global _idleCallRate
global _idleAllowErrors
if _idleTimer is not None:
_idleTimer.Stop()
......@@ -221,11 +229,12 @@ def idleReset():
if queue is not None: newQueue = queue.Queue()
else: newQueue = None
_idleRegistered = False
_idleQueue = newQueue
_idleQueueDict = {}
_idleTimer = None
_idleCallRate = 200
_idleRegistered = False
_idleQueue = newQueue
_idleQueueDict = {}
_idleTimer = None
_idleCallRate = 200
_idleAllowErrors = False
# Call idleReset on exit, in
......@@ -294,6 +303,7 @@ def _wxIdleLoop(ev):
global _idleQueueDict
global _idleTimer
global _idleCallRate
global _idleAllowErrors
ev.Skip()
......@@ -342,6 +352,9 @@ def _wxIdleLoop(ev):
log.warning('Idle task {} crashed - {}: {}'.format(
taskName, type(e).__name__, str(e)), exc_info=True)
if _idleAllowErrors:
raise e
if task.name is not None:
try: _idleQueueDict.pop(task.name)
except KeyError: pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment