more fixes for the pickle error.

This commit is contained in:
Storm Dragon
2025-11-23 18:37:21 -05:00
parent 77a3aae5a4
commit 87553bdc38
4 changed files with 23 additions and 5 deletions

View File

@@ -13,7 +13,19 @@ from fenrirscreenreader.core import debug
from fenrirscreenreader.core.eventData import FenrirEventType from fenrirscreenreader.core.eventData import FenrirEventType
# Standalone worker functions for multiprocessing (cannot be instance methods) # Standalone functions for multiprocessing (cannot be instance methods)
def _heart_beat_timer(running):
"""
Standalone heartbeat timer function for multiprocessing.
Returns current timestamp after a short sleep.
"""
try:
time.sleep(0.5)
except Exception as e:
print(f"ProcessManager _heart_beat_timer: Error during sleep: {e}")
return time.time()
def _custom_event_worker_process( def _custom_event_worker_process(
running, event_queue, function, pargs=None, run_once=False running, event_queue, function, pargs=None, run_once=False
): ):
@@ -81,7 +93,7 @@ class ProcessManager:
self.running = self.env["runtime"]["EventManager"].get_running() self.running = self.env["runtime"]["EventManager"].get_running()
self.add_simple_event_thread( self.add_simple_event_thread(
FenrirEventType.heart_beat, FenrirEventType.heart_beat,
self.heart_beat_timer, _heart_beat_timer,
multiprocess=True, multiprocess=True,
) )

View File

@@ -20,8 +20,10 @@ class driver(remoteDriver):
def initialize(self, environment): def initialize(self, environment):
self.env = environment self.env = environment
# Use threading instead of multiprocessing to avoid pickle issues
# with self.env (which contains unpicklable file handles)
self.env["runtime"]["ProcessManager"].add_custom_event_thread( self.env["runtime"]["ProcessManager"].add_custom_event_thread(
self.watch_dog, multiprocess=True self.watch_dog, multiprocess=False
) )
def watch_dog(self, active, event_queue): def watch_dog(self, active, event_queue):

View File

@@ -20,8 +20,10 @@ class driver(remoteDriver):
def initialize(self, environment): def initialize(self, environment):
self.env = environment self.env = environment
# Use threading instead of multiprocessing to avoid pickle issues
# with self.env (which contains unpicklable file handles)
self.env["runtime"]["ProcessManager"].add_custom_event_thread( self.env["runtime"]["ProcessManager"].add_custom_event_thread(
self.watch_dog, multiprocess=True self.watch_dog, multiprocess=False
) )
def watch_dog(self, active, event_queue): def watch_dog(self, active, event_queue):

View File

@@ -126,8 +126,10 @@ class driver(screenDriver):
"default", # fontfamily "default", # fontfamily
] ]
) # end attribute ) ) # end attribute )
# Use threading instead of multiprocessing to avoid pickle issues
# with self.env (which contains unpicklable file handles)
self.env["runtime"]["ProcessManager"].add_custom_event_thread( self.env["runtime"]["ProcessManager"].add_custom_event_thread(
self.update_watchdog, multiprocess=True self.update_watchdog, multiprocess=False
) )
def get_curr_screen(self): def get_curr_screen(self):