Address final code review nitpicks: improve code organization

Co-authored-by: denizsafak <39929354+denizsafak@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-20 23:29:23 +00:00
co-authored by denizsafak
parent 5cca6235e1
commit 711858ce2c
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -28,6 +28,9 @@ import threading # for efficient waiting
import subprocess
import platform
# Configuration constants
_USER_RESPONSE_TIMEOUT = 0.1 # Timeout in seconds for checking user response/cancellation
# Pre-compile frequently used regex patterns for better performance
_METADATA_TAG_PATTERN = re.compile(r"<<METADATA_[^:]+:[^>]*>>")
_CHAPTER_MARKER_PATTERN = re.compile(r"<<CHAPTER_MARKER:[^>]*>>")
@@ -875,10 +878,11 @@ class ConversionThread(QThread):
# Signal to ask user (-1 indicates timestamp detection)
self.chapters_detected.emit(-1)
# Wait for user response using event with timeout for responsive cancellation
while not self._timestamp_response_event.wait(timeout=0.1):
while not self._timestamp_response_event.wait(timeout=_USER_RESPONSE_TIMEOUT):
if self.cancel_requested:
self.conversion_finished.emit("Cancelled", None)
return
# Check cancellation one more time after event is set
if self.cancel_requested:
self.conversion_finished.emit("Cancelled", None)
return