This commit is contained in:
overcuriousity
2025-09-14 14:28:04 +02:00
parent 2185177a84
commit c91913fa13
3 changed files with 42 additions and 86 deletions

View File

@@ -198,7 +198,8 @@ class Scanner:
if self.scan_thread and self.scan_thread.is_alive():
print("A previous scan thread is still alive. Sending termination signal and waiting...")
self.stop_scan()
self.scan_thread.join(10.0)
# Wait for the thread to die, with a timeout
self.scan_thread.join(10.0)
if self.scan_thread.is_alive():
print("ERROR: The previous scan thread is unresponsive and could not be stopped.")
@@ -209,7 +210,8 @@ class Scanner:
# Reset state for new scan
self.status = ScanStatus.IDLE
self._update_session_state() # Update GUI immediately
# This update is crucial for the UI to reflect the reset before the new scan starts.
self._update_session_state()
print("Scanner state is now clean for a new scan.")
try:
@@ -225,7 +227,7 @@ class Scanner:
self.max_depth = max_depth
self.current_depth = 0
# Clear both local and Redis stop signals
# Clear both local and Redis stop signals for the new scan
self.stop_event.clear()
if self.session_id:
from core.session_manager import session_manager
@@ -235,14 +237,14 @@ class Scanner:
self.indicators_processed = 0
self.current_indicator = self.current_target
# Update GUI with scan preparation
# Update GUI with scan preparation state
self._update_session_state()
# Start new forensic session
print(f"Starting new forensic session for scanner {id(self)}...")
self.logger = new_session()
# Start scan in separate thread
# Start scan in a separate thread
print(f"Starting scan thread for scanner {id(self)}...")
self.scan_thread = threading.Thread(
target=self._execute_scan,
@@ -258,7 +260,8 @@ class Scanner:
print(f"ERROR: Exception in start_scan for scanner {id(self)}: {e}")
traceback.print_exc()
self.status = ScanStatus.FAILED
self._update_session_state() # Update failed status immediately
# Update GUI with failed status immediately
self._update_session_state()
return False
def _execute_scan(self, target_domain: str, max_depth: int) -> None:
@@ -648,7 +651,7 @@ class Scanner:
# Immediately update GUI with stopped status
self._update_session_state()
# Cancel executor futures if running
# Aggressively shut down the executor and cancel all pending tasks
if self.executor:
print("Shutting down executor with immediate cancellation...")
self.executor.shutdown(wait=False, cancel_futures=True)