sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

Provide client in activity context

Open dandavison opened this issue 11 months ago • 1 comments

Fixes https://github.com/temporalio/sdk-python/issues/721

dandavison avatar Jan 18 '25 04:01 dandavison

This needs a bit more work -- as things stand it's attempting to pickle the client in the context in tests of process-based executor pools (which fails when it tries to pickle the RuntimeRef), but I wonder if that means it is attempting to share the client across threads in thread-based executor pools.

dandavison avatar Jan 23 '25 23:01 dandavison

I'd be ok for now raising an exception for if the activity.client() is invoked in def activites (so async def activities only for now)

cretz avatar Jun 27 '25 15:06 cretz

Rebased and ready for review again.

Makes the worker's connected client.Client available in activities as activity.client().

As discussed above, the client is only available in async def activities.

dandavison avatar Jul 16 '25 01:07 dandavison