mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-05 21:20:40 +02:00
task: using functools to get correct func name
This commit is contained in:
parent
c00cf9a6ff
commit
861e89f37a
@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import functools
|
||||
import logging
|
||||
from collections.abc import Callable, Coroutine
|
||||
from typing import Any, Concatenate, ParamSpec, TypeVar
|
||||
@ -17,6 +18,7 @@ def task(
|
||||
def decorator(
|
||||
func: Callable[Concatenate[Any, P], Coroutine[None, None, R]],
|
||||
) -> Task[P, R]:
|
||||
@functools.wraps(func)
|
||||
async def wrapper(self: Any, *args: P.args, **kwargs: P.kwargs) -> R | None:
|
||||
try:
|
||||
return await func(self, *args, **kwargs)
|
||||
|
@ -61,7 +61,7 @@ class Task(pydase.DataService, Generic[P, R]):
|
||||
|
||||
self._result = task.result()
|
||||
|
||||
logger.info("Starting task")
|
||||
logger.info("Starting task %s", self._func.__name__)
|
||||
if inspect.iscoroutinefunction(self._bound_func):
|
||||
res: Coroutine[None, None, R] = self._bound_func(*args, **kwargs)
|
||||
self._task = asyncio.create_task(res)
|
||||
|
Loading…
x
Reference in New Issue
Block a user