diff --git a/lblprof/custom_sysmon.py b/lblprof/custom_sysmon.py index 243ad4b..2423c3d 100644 --- a/lblprof/custom_sysmon.py +++ b/lblprof/custom_sysmon.py @@ -168,7 +168,14 @@ def _handle_return(self, code, instruction_offset, retval): def start_tracing(self) -> None: # Reset state self.__init__() - sys.monitoring.use_tool_id(self.tool_id, "lblprof-monitor") + if not sys.monitoring.get_tool(self.tool_id): + sys.monitoring.use_tool_id(self.tool_id, "lblprof-monitor") + else: + # if the tool already assigned is not ours, we need to raise an error + if sys.monitoring.get_tool(self.tool_id) != "lblprof-monitor": + raise RuntimeError( + "A tool with the id lblprof-monitor is already assigned, please stop it before starting a new tracing" + ) # Register our callback functions sys.monitoring.register_callback( diff --git a/pyproject.toml b/pyproject.toml index f2ab3f0..9a52a05 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "lblprof" -version = "0.1.7" +version = "0.1.8" description = "Line by line terminal based profiler" authors = [ { name="le-codeur-rapide", email="paul.vezia@gmail.com" }