Skip to content

Commit 2677658

Browse files
committed
Fix registration of sync functions
1 parent 8aa6795 commit 2677658

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/dispatch/function.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,28 +182,28 @@ def function(self, func: Callable[P, T]) -> Function[P, T]: ...
182182

183183
def function(self, func):
184184
"""Decorator that registers functions."""
185+
name = func.__qualname__
185186
if not inspect.iscoroutinefunction(func):
186-
logger.info("registering function: %s", func.__qualname__)
187-
return self._register_function(func)
187+
logger.info("registering function: %s", name)
188+
return self._register_function(name, func)
188189

189-
logger.info("registering coroutine: %s", func.__qualname__)
190-
return self._register_coroutine(func)
190+
logger.info("registering coroutine: %s", name)
191+
return self._register_coroutine(name, func)
191192

192-
def _register_function(self, func: Callable[P, T]) -> Function[P, T]:
193+
def _register_function(self, name: str, func: Callable[P, T]) -> Function[P, T]:
193194
func = durable(func)
194195

195196
@wraps(func)
196197
async def async_wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
197198
return func(*args, **kwargs)
198199

199-
async_wrapper.__qualname__ = f"{func.__qualname__}_async"
200+
async_wrapper.__qualname__ = f"{name}_async"
200201

201-
return self._register_coroutine(async_wrapper)
202+
return self._register_coroutine(name, async_wrapper)
202203

203204
def _register_coroutine(
204-
self, func: Callable[P, Coroutine[Any, Any, T]]
205+
self, name: str, func: Callable[P, Coroutine[Any, Any, T]]
205206
) -> Function[P, T]:
206-
name = func.__qualname__
207207
logger.info("registering coroutine: %s", name)
208208

209209
func = durable(func)

0 commit comments

Comments
 (0)