Skip to content

Commit 4657453

Browse files
authored
Async activity support and describe interceptor (#32)
Fixes #24
1 parent 47be211 commit 4657453

File tree

4 files changed

+428
-35
lines changed

4 files changed

+428
-35
lines changed

temporalio/activity.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import asyncio
1313
import contextvars
14+
import dataclasses
1415
import inspect
1516
import logging
1617
import threading
@@ -346,7 +347,14 @@ class _Definition:
346347

347348
@staticmethod
348349
def from_callable(fn: Callable) -> Optional[_Definition]:
349-
return getattr(fn, "__temporal_activity_definition", None)
350+
defn = getattr(fn, "__temporal_activity_definition", None)
351+
if isinstance(defn, _Definition):
352+
# We have to replace the function with the given callable here
353+
# because the one passed in may be a method or some other partial
354+
# that represents the real callable instead of what the decorator
355+
# used.
356+
defn = dataclasses.replace(defn, fn=fn)
357+
return defn
350358

351359
@staticmethod
352360
def must_from_callable(fn: Callable) -> _Definition:

0 commit comments

Comments
 (0)