From 09fae019852a7807066647dfaf68f5b311501550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Tue, 6 Aug 2024 11:17:36 +0200 Subject: [PATCH] adds warning when _bound_func has not been bound yet This might arise when calling the start method of a task which is part of a class that has not been instantiated yet. --- src/pydase/task/task.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pydase/task/task.py b/src/pydase/task/task.py index 85b8d12..5b768d6 100644 --- a/src/pydase/task/task.py +++ b/src/pydase/task/task.py @@ -70,10 +70,7 @@ class Task(pydase.data_service.data_service.DataService, Generic[R]): Removes a task from the tasks dictionary, calls the defined callbacks, and logs and re-raises exceptions.""" - # removing the finished task from the tasks i self._task = None - - # emit the notification that the task was stopped self._status = TaskStatus.NOT_RUNNING exception = task.exception() @@ -95,6 +92,9 @@ class Task(pydase.data_service.data_service.DataService, Generic[R]): self._status = TaskStatus.RUNNING res: Coroutine[None, None, R] = self._bound_func() return await res + logger.warning( + "Cannot start task %r. Function has not been bound yet", self._func_name + ) return None logger.info("Creating task %r", self._func_name)