port mutex sample from go repository - #200
Conversation
|
|
| return f"unlock-event-{sender_workflow_id}" | ||
|
|
||
|
|
||
| @workflow.defn |
There was a problem hiding this comment.
I think we may not want to blind-port this from Go but have a more Pythonic way to do a mutex and we want to make sure workflows are in their own files separate from activities/models. For instance, the .NET version of this sample at https://github.com/temporalio/samples-dotnet/tree/main/src/Mutex made an idiomatic WorkflowMutex class for general purpose use. I think this sample should consider a workflow-backed Lock class that looks almost exactly like https://docs.python.org/3/library/asyncio-sync.html#asyncio.Lock and is copyable/usable as if it is a library.
There was a problem hiding this comment.
write permissions required into the code before lock can be engaged
|
@K-Yo — checking in here, sorry for the long delay. Still interested in reworking it? If we don't hear back in the next couple of weeks we'll close it out, and you're welcome to reopen whenever. |
What was changed
Added a python sample for mutex pattern
Why?
The sample exists for go sdk but not for python yet. I needed it so I figured I could share it.
Checklist
I’ve left a TODO in the code, I am not sure how to properly distinguish who sends a release in python (even if sender workflows are supposed to send them in order)
ran it locally with latest temporal dev server, and using branch pyproject.toml configuration.
not that I think of