Skip to content

Commit

Permalink
feat: deep copy supervisor config before giving it out to daq jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
furkan-bilgin committed Nov 10, 2024
1 parent 624a323 commit f648ae4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/daq/daq_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def build_daq_job(toml_config: bytes, supervisor_config: SupervisorConfig) -> DA
# Load the config in
config = msgspec.toml.decode(toml_config, type=daq_job_config_class)

return daq_job_class(config, supervisor_config=supervisor_config)
return daq_job_class(config, supervisor_config=supervisor_config.clone())


def load_daq_jobs(
Expand Down Expand Up @@ -64,7 +64,9 @@ def restart_daq_job(
supervisor_config: SupervisorConfig,
) -> DAQJobThread:
logging.info(f"Restarting {daq_job_type.__name__}")
new_daq_job = daq_job_type(daq_job_config, supervisor_config=supervisor_config)
new_daq_job = daq_job_type(
daq_job_config, supervisor_config=supervisor_config.clone()
)
thread = threading.Thread(target=new_daq_job.start, daemon=True)
thread.start()
return DAQJobThread(new_daq_job, thread)
Expand Down
6 changes: 6 additions & 0 deletions src/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from copy import deepcopy

from msgspec import Struct


class SupervisorConfig(Struct):
supervisor_id: str

def clone(self):
print(deepcopy(self))
return deepcopy(self)

0 comments on commit f648ae4

Please sign in to comment.