Skip to content

Commit 928f4e5

Browse files
committed
fix: Fix async activity test for Python 3.9 compatibility
- Remove module-level asyncio.Event that causes event loop issues in Python 3.9 - Use asyncio.sleep instead of event to wait for activity start - Activity now signals start via heartbeat instead of event
1 parent b5cadec commit 928f4e5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tests/test_serialization_context.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,6 @@ async def test_workflow_payload_conversion(
324324
pprint(result.items)
325325

326326

327-
async_activity_started = asyncio.Event()
328-
329-
330327
# Activity with heartbeat details test
331328
@activity.defn
332329
async def activity_with_heartbeat_details() -> TraceData:
@@ -420,7 +417,8 @@ async def test_heartbeat_details_payload_conversion(client: Client):
420417
# Async activity completion test
421418
@activity.defn
422419
async def async_activity() -> TraceData:
423-
async_activity_started.set()
420+
# Signal that activity has started via heartbeat
421+
activity.heartbeat("started")
424422
activity.raise_complete_async()
425423

426424

@@ -462,7 +460,8 @@ async def test_async_activity_completion_payload_conversion(
462460
run_id=wf_handle.first_execution_run_id,
463461
activity_id="async-activity-id",
464462
)
465-
await async_activity_started.wait()
463+
# Wait a bit for the activity to start
464+
await asyncio.sleep(0.5)
466465
data = TraceData()
467466
await activity_handle.heartbeat(data)
468467
await activity_handle.complete(data)

0 commit comments

Comments
 (0)