Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give threads names upon creation, making its responsibility visible #77

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pyzeebe/worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def work(self) -> None:

"""
for task in self.tasks:
task_thread = Thread(target=self._handle_task, args=(task,))
task_thread = Thread(target=self._handle_task,
args=(task,),
name=f"{self.__class__.__name__}-Task-{task.type}")
task_thread.start()

def stop(self) -> None:
Expand All @@ -70,7 +72,9 @@ def _handle_task(self, task: Task) -> None:

def _handle_jobs(self, task: Task) -> None:
for job in self._get_jobs(task):
thread = Thread(target=task.handler, args=(job,))
thread = Thread(target=task.handler,
args=(job,),
name=f"{self.__class__.__name__}-Job-{job.type}")
logger.debug(f"Running job: {job}")
thread.start()

Expand Down