Skip to content

Commit

Permalink
fix: Fix __del__ and rename create_processes to setup (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab authored Aug 16, 2024
1 parent 1486777 commit c4654d7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/retsu/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def __init__(self, workers: int = 1) -> None:
def __del__(self) -> None:
"""Close queues and process."""
logging.info(f"Deleting process {self.__class__.__name__}")
self.stop()

@public
def start(self) -> None:
Expand Down Expand Up @@ -145,13 +144,13 @@ def __init__(self) -> None:
self.tasks: dict[str, Process] = {}

@public
def create_processes(self) -> None:
def setup(self) -> None:
"""Get a process with the given name."""
if self.tasks:
return

warnings.warn(
"`self.tasks` is empty. Override `create_processes` and create "
"`self.tasks` is empty. Override `setup` and create "
"`self.tasks` with the proper tasks."
)

Expand All @@ -164,7 +163,7 @@ def get_process(self, name: str) -> Optional[Process]:
def start(self) -> None:
"""Start tasks."""
if not self.tasks:
self.create_processes()
self.setup()

for task_name, process in self.tasks.items():
process.start()
Expand Down

0 comments on commit c4654d7

Please sign in to comment.