Both the main function (offer
) and the new function (process_interrupt
) are python generators. So in fact you want to divide a generator into two generators. There is a special syntax for delegating to a subgenerator (PEP 380):
yield from <expr>
When
action = process_interrupt(action, simpy_car, simpy_tankcar)
is replaced by
action = yield from process_interrupt(action, simpy_car, simpy_tankcar)
everything works fine.