Browse Source

Also set pthread name in startup, for what it is worth

tags/v0.1
Nils 1 year ago
parent
commit
4939a44ffb
1 changed files with 29 additions and 2 deletions
  1. +29
    -2
      engine/start.py

+ 29
- 2
engine/start.py View File

@@ -152,7 +152,7 @@ def setProcessName(executableName):
"""From
https://stackoverflow.com/questions/31132342/change-process-name-while-executing-a-python-script
"""
import ctypes
import ctypes, ctypes.util
lib = ctypes.cdll.LoadLibrary(None)
prctl = lib.prctl
prctl.restype = ctypes.c_int
@@ -164,6 +164,28 @@ def setProcessName(executableName):
raise OSError("prctl result: %d" % result)
set_proctitle(executableName.encode())


libpthread_path = ctypes.util.find_library("pthread")
if not libpthread_path:
return
libpthread = ctypes.CDLL(libpthread_path)
if hasattr(libpthread, "pthread_setname_np"):
_pthread_setname_np = libpthread.pthread_setname_np

_pthread_self = libpthread.pthread_self
_pthread_self.argtypes = []
_pthread_self.restype = ctypes.c_void_p

_pthread_setname_np.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
_pthread_setname_np.restype = ctypes.c_int

if _pthread_setname_np is None:
return
_pthread_setname_np(_pthread_self(), executableName.encode())

def _is_jack_running():
"""Check for JACK"""
import ctypes
@@ -195,7 +217,12 @@ def checkJackOrExit(prettyName):


checkJackOrExit(METADATA["name"])
setProcessName(METADATA["shortName"])

try:
#Only cosmetics
setProcessName(METADATA["shortName"])
except:
pass


#Catch Exceptions even if PyQt crashes.

Loading…
Cancel
Save