Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-6301: PyGhidra 3.0.2 now uses TaskMonitor.DUMMY instead of PyGhidraTaskMonitor if no timeout is specified (#8858)

Ryan Kurtz03740023b74c
diff --git a/Ghidra/Features/PyGhidra/src/main/py/README.md b/Ghidra/Features/PyGhidra/src/main/py/README.md
index ed42b65a94..7b89d0f661 100644
--- a/Ghidra/Features/PyGhidra/src/main/py/README.md
+++ b/Ghidra/Features/PyGhidra/src/main/py/README.md
@@ -228,12 +228,12 @@ def program_loader() -> "ProgramLoader.Builder":
```python
def task_monitor(
timeout: Optional[int] = None
- ) -> "PyGhidraTaskMonitor":
+ ) -> "TaskMonitor":
"""
- Convenience function to get a "PyGhidraTaskMonitor" object.
+ Convenience function to get a "TaskMonitor" object.
:param timeout: An optional number of seconds to wait before canceling the monitor.
- :return: A "PyGhidraTaskMonitor" object.
+ :return: A "TaskMonitor" object.
"""
```
@@ -570,7 +570,9 @@ import pdb_ # imports Ghidra's pdb
__3.0.2__
* Fixed an issue that prevented [`pyghidra.analysis_properties()`](#pyghidraanalysis_properties)
from having access to all of the analysis properties.
-* Fixed issues related to the PyGhidra API inadvertently squashing exceptions
+* Fixed issues related to the PyGhidra API inadvertently squashing exceptions.
+* Calling [`pyghidra.task_monitor()`](#pyghidratask_monitor) with no `timeout` parameter will now
+ return a `TaskMonitor.DUMMY` instead of a `PyGhidraTaskMonitor`.
__3.0.1__
* Fixed `AttributeError: module 'pyghidra' has no attribute 'program_conext'` when performing a
diff --git a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py
index 7fe59fe968..72cfc1d15c 100644
--- a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py
+++ b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py
@@ -305,17 +305,20 @@ def program_loader() -> "ProgramLoader.Builder":
def task_monitor(
timeout: Optional[int] = None
- ) -> "PyGhidraTaskMonitor":
+ ) -> "TaskMonitor":
"""
- Convenience function to get a "PyGhidraTaskMonitor" object.
+ Convenience function to get a "TaskMonitor" object.
:param timeout: An optional number of seconds to wait before canceling the monitor.
- :return: A "PyGhidraTaskMonitor" object.
+ :return: A "TaskMonitor" object.
"""
+ from ghidra.util.task import TaskMonitor
from ghidra.pyghidra import PyGhidraTaskMonitor
from jpype.types import JInt
- t = None if timeout is None else JInt(timeout)
- return PyGhidraTaskMonitor(t, None)
+ if timeout is None:
+ return TaskMonitor.DUMMY
+ else:
+ return PyGhidraTaskMonitor(JInt(timeout), None)
def walk_project(
project: "Project",