Hand Off to a Resource
A handoff passes an order from one resource to the next without letting go of the first too early. Here a picker carries each order to a packing bench. The picker stays with the order until the bench is free. For a moment the order holds both resources, and then it releases the picker.

Before You Start
- Competing Resources measures what holding two resources costs.
- Several Resources describes
keepand the rule on the order of acquisition.
Steps
- Give the first task the resource and
keepit:pickholds the picker and hands it to the next task. - Give the next task the second resource:
packwaits for the bench while the order still holds the picker, and gives the picker back once it publishesstarted. - Acquire the two resources in the same order everywhere. A task that takes the bench first and the picker second would be refused when the model is built, because two orders could then wait for each other for ever.
In the low-level API, pick passes its granted request to pack, which releases it in place of a with block:
Check the Result
Save the files from Full Files and run desflow run multi_resource_handoffs.yaml, python multi_resource_handoffs.py or python multi_resource_handoffs_low_level.py. Each runs for 30 seconds in real time and prints each event, and the three print the same events, because they use the same seed, 42.
Each order is queued for the picker, picked, queued for the bench and packed, in that order. Orders arrive about once a second, and the one bench takes 4 seconds to pack each, so it can pack only one order every 4 seconds. The bench is therefore the bottleneck: an order that waits for the bench keeps the picker, and the orders behind it wait for the picker.
A task that needs both resources for the whole of its work lists them instead, resource: [picker, bench]. The competing-resources example on Several Resources has both kinds.