Closed giuliohome closed 1 month ago
Uhm ... I see... they need to run in parallel
@workflow.defn
class GreetingWorkflow:
@workflow.run
async def run(self, name: str) -> str:
task1 = asyncio.create_task( workflow.execute_activity(
compose_greeting,
ComposeGreetingInput("Hello", name),
start_to_close_timeout=timedelta(seconds=10),
# Always set a heartbeat timeout for long-running activities
heartbeat_timeout=timedelta(seconds=2),
))
task2 = asyncio.create_task( workflow.execute_activity(
compose_greeting,
ComposeGreetingInput("Hello", name),
start_to_close_timeout=timedelta(seconds=10),
# Always set a heartbeat timeout for long-running activities
heartbeat_timeout=timedelta(seconds=2),
) )
ret1 = await task1
ret2 = await task2
return ret1 + " and then " + ret2
in that case
python multiprocessor_giulio.py
Heartbeating activity on PID 4952
Heartbeating activity on PID 5904
Heartbeating activity on PID 4952
Heartbeating activity on PID 5904
Heartbeating activity on PID 4952
Heartbeating activity on PID 5904
Result on PID 11484: Hello, World from activity on PID 4952! and then Hello, World from activity on PID 5904!
What are you really trying to do?
This is a follow up to this message, in particular I'm simply running this official sample https://github.com/temporalio/samples-python/blob/main/hello/hello_activity_multiprocess.py
Describe the bug
I see this output
I would have expected to see a different PID when the activity runs the second time!
Minimal Reproduction
I have taken the official sample and simply repeated the activity execution two times inside the workflow
and I have also modified the activity to print its PID in the hello message
Environment/Versions
Temporal Version: Latest temporal version, latest SDK version temporal server start-dev CLI 1.1.0 (Server 1.25.0, UI 2.30.3)
Are you using Docker or Kubernetes or building Temporal from source? Nope