Skip to content

Commit d1ce3bc

Browse files
authored
Try to log exceptions in IoThread (nvaccess#14899)
Summary of the issue: I'm still seeing access violations in the IoThread here and there, same for @bramd. I really want to track these down! We need to handle those more gracefully anyway. Description of user facing changes Better logging Description of development approach De run block of the IOThread is now wrapped in a try/except that logs the stack. I hope the stack will give us more info about what's going wrong here.
1 parent 345154a commit d1ce3bc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

source/hwIo/ioThread.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from inspect import ismethod
1818
from buildVersion import version_year
1919
import NVDAState
20+
from watchdog import getFormattedStacksForAllThreads
2021

2122
LPOVERLAPPED_COMPLETION_ROUTINE = ctypes.WINFUNCTYPE(
2223
None,
@@ -197,7 +198,12 @@ def fakeApc(param):
197198
self.handle = None
198199

199200
def run(self):
200-
while True:
201-
ctypes.windll.kernel32.SleepEx(winKernel.INFINITE, True)
202-
if self.exit:
203-
break
201+
try:
202+
while True:
203+
ctypes.windll.kernel32.SleepEx(winKernel.INFINITE, True)
204+
if self.exit:
205+
break
206+
except Exception:
207+
log.critical("Exception in IoThread function", exc_info=True)
208+
stacks = getFormattedStacksForAllThreads()
209+
log.info(f"Listing stacks for Python threads after IoThread crash:\n{stacks}")

0 commit comments

Comments
 (0)