From: Fredrik Tolf Date: Tue, 11 Jun 2024 14:09:50 +0000 (+0200) Subject: Add reload function to perf.sysctl. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=6e858b0f28a9443fb3a67121c828648c77a8078c;p=pdm.git Add reload function to perf.sysctl. --- diff --git a/pdm/perf.py b/pdm/perf.py index 7aef95a..7c93c85 100644 --- a/pdm/perf.py +++ b/pdm/perf.py @@ -278,4 +278,12 @@ sysinfo["uname"] = simpleattr(func = os.uname) sysinfo["hostname"] = simpleattr(func = socket.gethostname) sysinfo["platform"] = valueattr(init = sys.platform) -sysctl = simplefunc(exit=lambda status=0: os._exit(status)) +def reload(modname): + mod = sys.modules.get(modname) + if mod is None: + raise ValueError(modname) + import importlib + importlib.reload(mod) + +sysctl = simplefunc(exit=lambda status=0: os._exit(status), + reload=reload)