Skip to content

Commit

Permalink
recording_table now requires locking
Browse files Browse the repository at this point in the history
  • Loading branch information
dcnieho committed Sep 23, 2024
1 parent c72b0f8 commit 8f2e5be
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
glassesTools[GUI]==1.10.5 # pulls in various other dependencies such as imgui_bundle, matplotlib, numpy, opencv, pandas, polars
glassesTools[GUI]==1.10.6 # pulls in various other dependencies such as imgui_bundle, matplotlib, numpy, opencv, pandas, polars
I2MC
aiosqlite
uvloop ; sys_platform != "win32"
Expand Down
4 changes: 3 additions & 1 deletion src/glassesValidator/GUI/_impl/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
import pandas as pd
import dataclasses
import threading
from imgui_bundle import icons_fontawesome_6 as ifa6

from glassesTools import async_thread, platform, recording
Expand Down Expand Up @@ -148,7 +149,8 @@ def prepping_recs_popup():
recordings_selected_to_add[id] = True

item_context_menu = lambda iid: gui.draw_recording_open_folder_button(recordings_to_add[iid], label=ifa6.ICON_FA_FOLDER_OPEN+" Open Folder", source_dir=True)
recording_list = recording_table.RecordingTable(recordings_to_add, recordings_selected_to_add, [], None, item_context_menu)
recording_lock = threading.Lock()
recording_list = recording_table.RecordingTable(recordings_to_add, recording_lock, recordings_selected_to_add, [], None, item_context_menu)
recording_list.set_local_item_remover()
def list_recs_popup():
nonlocal recording_list
Expand Down
2 changes: 2 additions & 0 deletions src/glassesValidator/GUI/_impl/globals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pathlib
import sys
import threading

from glassesTools import platform

Expand Down Expand Up @@ -45,6 +46,7 @@
settings: Settings = None
rec_id: CounterContext = CounterContext()
recordings: dict[int, Recording] = None
recording_lock = threading.Lock()
selected_recordings: dict[int, bool] = None
jobs: dict[int, JobDescription] = None
coding_job_queue: dict[int, JobDescription] = None
Expand Down
9 changes: 5 additions & 4 deletions src/glassesValidator/GUI/_impl/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ def worker_process_done_hook(future: pebble.ProcessFuture, job_id: int, state: P
if not found:
# nothing to do because no job with this id (shouldn't occur)
return
if rec_id not in globals.recordings:
rec = globals.recordings.get(rec_id, None)
if rec is None:
# might happen if recording already removed
return
rec = globals.recordings[rec_id]

del globals.jobs[rec_id]
match state:
Expand All @@ -285,7 +285,8 @@ def worker_process_done_hook(future: pebble.ProcessFuture, job_id: int, state: P
rec.task = job.task
async_thread.run(db.update_recording(rec, "task"))
if job.task == Task.Imported:
globals.gui.update_recordings([rec_id])
with globals.recording_lock:
globals.gui.update_recordings([rec_id])
# start next step, if wanted
if job.should_chain_next:
if (job.task==Task.Coded and globals.settings.continue_process_after_code) or job.task!=Task.Imported:
Expand Down Expand Up @@ -613,7 +614,7 @@ def load_interface(self, is_reload = False):
self.init_imgui_glfw(is_reload=is_reload)
if globals.project_path is not None:
task_column = recording_table.ColumnSpec(2,ifa6.ICON_FA_SQUARE_POLL_VERTICAL+" Status",imgui.TableColumnFlags_.no_resize,draw_recording_status_widget,lambda iid: task_names.index(globals.recordings[iid].task.value),ifa6.ICON_FA_SQUARE_POLL_VERTICAL)
self.recording_list = recording_table.RecordingTable(globals.recordings, globals.selected_recordings, [task_column], None, draw_recordings_context_menu, empty_space_context_menu, remove_recording)
self.recording_list = recording_table.RecordingTable(globals.recordings, globals.recording_lock, globals.selected_recordings, [task_column], None, draw_recordings_context_menu, empty_space_context_menu, remove_recording)

def update_recordings(self, subset=None):
if not subset:
Expand Down

0 comments on commit 8f2e5be

Please sign in to comment.