Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion source/NVDAObjects/behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ def startMonitoring(self):
"""
if self._monitorThread:
return
thread = self._monitorThread = threading.Thread(target=self._monitor)
thread = self._monitorThread = threading.Thread(
name=f"{self.__class__.__qualname__}._monitorThread",
>
)
thread.daemon = True
self._keepMonitoring = True
self._event.clear()
Expand Down
5 changes: 4 additions & 1 deletion source/_UIAHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ def __init__(self):
self.MTAThreadInitEvent=threading.Event()
self.MTAThreadStopEvent=threading.Event()
self.MTAThreadInitException=None
self.MTAThread=threading.Thread(target=self.MTAThreadFunc)
self.MTAThread = threading.Thread(
name=f"{self.__class__.__module__}.{self.__class__.__qualname__}.MTAThread",
>
)
self.MTAThread.daemon=True
self.MTAThread.start()
self.MTAThreadInitEvent.wait(2)
Expand Down
5 changes: 4 additions & 1 deletion source/braille.py
Original file line number Diff line number Diff line change
Expand Up @@ -2030,7 +2030,10 @@ def start(cls):
if cls.thread:
return
cls.queuedWriteLock = threading.Lock()
thread = cls.thread = threading.Thread(target=cls.func)
thread = cls.thread = threading.Thread(
name=f"{cls.__module__}.{cls.__qualname__}",
>
)
thread.daemon = True
thread.start()
cls.handle = ctypes.windll.kernel32.OpenThread(winKernel.THREAD_SET_CONTEXT, False, thread.ident)
Expand Down
9 changes: 9 additions & 0 deletions source/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,15 @@ class ExecAndPump(threading.Thread):
"""Executes the given function with given args and kwargs in a background thread while blocking and pumping in the current thread."""

def __init__(self,func,*args,**kwargs):
if hasattr(func, "__qualname__"): # _FuncPtr doesn't have this
if hasattr(func, "__func__"):
fname = func.__func__.__module__
else:
fname = func.__module__
fname += f".{func.__qualname__}"
else:
fname = repr(func)
self.name = f"{self.__class__.__module__}.{self.__class__.__qualname__}({fname})"
self.func=func
self.args=args
self.kwargs=kwargs
Expand Down
23 changes: 15 additions & 8 deletions source/logHandler.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#logHandler.py
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2007-2019 NV Access Limited, Rui Batista, Joseph Lee, Leonard de Ruijter
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
# A part of NonVisual Desktop Access (NVDA)
# Copyright (C) 2007-2019 NV Access Limited, Rui Batista, Joseph Lee, Leonard de Ruijter, Babbage B.V.
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.

"""Utilities and classes to manage logging in NVDA"""

Expand Down Expand Up @@ -226,6 +225,8 @@ def handle(self,record):
return super().handle(record)

class Formatter(logging.Formatter):
default_time_format = "%H:%M:%S"
default_msec_format = "%s.%03d"

def formatException(self, ex):
return stripBasePathFromTracebackText(super(Formatter, self).formatException(ex))
Expand Down Expand Up @@ -295,9 +296,12 @@ def initialize(shouldDoRemoteLogging=False):
logging.addLevelName(Logger.OFF, "OFF")
if not shouldDoRemoteLogging:
# This produces log entries such as the following:
# IO - inputCore.InputManager.executeGesture (09:17:40.724):
# IO - inputCore.InputManager.executeGesture (09:17:40.724) - Thread-5 (13576):
# Input: kb(desktop):v
logFormatter=Formatter("%(levelname)s - %(codepath)s (%(asctime)s.%(msecs)03d):\n%(message)s", "%H:%M:%S")
logFormatter = Formatter(
fmt="{levelname!s} - {codepath!s} ({asctime}) - {threadName} ({thread}):\n{message}",
style="{"
)
if (globalVars.appArgs.secure or globalVars.appArgs.noLogging) and (not globalVars.appArgs.debugLogging and globalVars.appArgs.logLevel == 0):
# Don't log in secure mode.
# #8516: also if logging is completely turned off.
Expand All @@ -319,7 +323,10 @@ def initialize(shouldDoRemoteLogging=False):
logHandler = FileHandler(globalVars.appArgs.logFileName, mode="w",encoding="utf-8")
else:
logHandler = RemoteHandler()
logFormatter = Formatter("%(codepath)s:\n%(message)s")
logFormatter = Formatter(
fmt="{codepath!s}:\n{message}",
style="{"
)
logHandler.setFormatter(logFormatter)
log.addHandler(logHandler)
redirectStdout(log)
Expand Down
6 changes: 5 additions & 1 deletion source/nvwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import wave
import config
from logHandler import log
import os.path

__all__ = (
"WavePlayer", "getOutputDeviceNames", "outputDeviceIDToName", "outputDeviceNameToID",
Expand Down Expand Up @@ -398,7 +399,10 @@ def playWaveFile(fileName, asynchronous=True):
if asynchronous:
if fileWavePlayerThread is not None:
fileWavePlayerThread.join()
fileWavePlayerThread=threading.Thread(target=fileWavePlayer.idle)
fileWavePlayerThread = threading.Thread(
name=f"{__name__}.playWaveFile({os.path.basename(fileName)})",
>
)
fileWavePlayerThread.start()
else:
fileWavePlayer.idle()
Expand Down
5 changes: 4 additions & 1 deletion source/remotePythonConsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def initialize():
global server
server = socketserver.TCPServer(("", PORT), RequestHandler)
server.daemon_threads = True
thread = threading.Thread(target=server.serve_forever)
thread = threading.Thread(
name=__name__, # remotePythonConsole
>
)
thread.daemon = True
thread.start()

Expand Down
2 changes: 1 addition & 1 deletion source/synthDrivers/_espeak.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def callback(wav,numsamples,event):

class BgThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
super().__init__(name=f"{self.__class__.__module__}.{self.__class__.__qualname__}")
self.setDaemon(True)

def run(self):
Expand Down
3 changes: 1 addition & 2 deletions source/touchHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,9 @@ def getDisplayTextForIdentifier(cls, identifier):
inputCore.registerGestureSource("ts", TouchInputGesture)

class TouchHandler(threading.Thread):

def __init__(self):
self.pendingEmitsTimer=gui.NonReEntrantTimer(core.requestPump)
super(TouchHandler,self).__init__()
super().__init__(name=f"{self.__class__.__module__}.{self.__class__.__qualname__}")
self._curTouchMode='object'
self.initializedEvent=threading.Event()
self.threadExc=None
Expand Down
10 changes: 8 additions & 2 deletions source/updateCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ class UpdateChecker(object):
def check(self):
"""Check for an update.
"""
t = threading.Thread(target=self._bg)
t = threading.Thread(
name=f"{self.__class__.__module__}.{self.check.__qualname__}",
>
)
t.daemon = True
self._started()
t.start()
Expand Down Expand Up @@ -580,7 +583,10 @@ def start(self):
style=wx.PD_CAN_ABORT | wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME | wx.PD_AUTO_HIDE,
parent=gui.mainFrame)
self._progressDialog.Raise()
t = threading.Thread(target=self._bg)
t = threading.Thread(
name=f"{self.__class__.__module__}.{self.start.__qualname__}",
>
)
t.daemon = True
t.start()

Expand Down
5 changes: 4 additions & 1 deletion source/virtualBuffers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,10 @@ def _get_isReady(self):
def loadBuffer(self):
self.isLoading = True
self._loadProgressCallLater = wx.CallLater(1000, self._loadProgress)
threading.Thread(target=self._loadBuffer).start()
threading.Thread(
name=f"{self.__class__.__module__}.{self.loadBuffer.__qualname__}",
>
)

def _loadBuffer(self):
try:
Expand Down
5 changes: 4 additions & 1 deletion source/visionEnhancementProviders/NVDAHighlighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ def __init__(self):
self.contextToRectMap = {}
winGDI.gdiPlusInitialize()
self.window = None
self._highlighterThread = threading.Thread(target=self._run)
self._highlighterThread = threading.Thread(
name=f"{self.__class__.__module__}.{self.__class__.__qualname__}",
>
)
self._highlighterThread.daemon = True
self._highlighterThread.start()

Expand Down
14 changes: 13 additions & 1 deletion source/watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ def initialize():
"cancelCallEvent")
# Handle cancelled SendMessage calls.
NVDAHelper._setDllFuncPointer(NVDAHelper.localLib, "_notifySendMessageCancelled", _notifySendMessageCancelled)
_watcherThread=threading.Thread(target=_watcher)
_watcherThread = threading.Thread(
name=__name__,
>
)
alive()
_watcherThread.start()

Expand Down Expand Up @@ -254,6 +257,15 @@ def __init__(self):
self.isUsable = True

def execute(self, func, *args, pumpMessages=True, **kwargs):
if hasattr(func, "__qualname__"): # _FuncPtr doesn't have this
if hasattr(func, "__func__"):
fname = func.__func__.__module__
else:
fname = func.__module__
fname += f".{func.__qualname__}"
else:
fname = repr(func)
self.name = f"{self.__class__.__module__}.{self.execute.__qualname__}({fname})"
# Don't even bother making the call if the core is already dead.
if isAttemptingRecovery:
raise CallCancelled
Expand Down
14 changes: 8 additions & 6 deletions source/winInputHook.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#winInputHook.py
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2006-2008 NVDA Contributors <http://www.nvda-project.org/>
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
# A part of NonVisual Desktop Access (NVDA)
# Copyright (C) 2006-2019 NV Access Limited
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.

import threading
import comtypes.client
Expand Down Expand Up @@ -88,7 +87,10 @@ def initialize():
global hookThread, hookThreadRefCount
hookThreadRefCount+=1
if hookThreadRefCount==1:
hookThread=threading.Thread(target=hookThreadFunc)
hookThread = threading.Thread(
name=__name__, # winInputHook
>
)
hookThread.start()

def setCallbacks(keyUp=None,keyDown=None,mouse=None):
Expand Down