|
Pythomnic » Documentation » Architecture (cage structure) » Cage-to-cage communications » Call chains
A call chain is essentially a sequence of calls from one cage to another,
where each call is executed as a P2P message queued call as explained
in the previous section.
For example, the pmnc_chain.start construct
pmnc_chain.start("target_cage.target_module.target_method", *args, **kwargs)
behaves pretty much the same as
pmnc.execute.on("target_cage_queue").target_module.target_method(*args, **kwargs)
but it also (as its name implies) initiates a separate call chain, so that the target_method
is already being executed in a context of the created chain and therefore can use the
pmnc_chain.next construct to proceed to the next call:
# on target cage, in target_module.py
def target_method(*args, **kwargs):
# do something, then proceed to the next call in the chain
do_stuff()
pmnc_chain.next("next_cage.next_module.next_method", *args, **kwargs)
Here pmnc_chain.next has the same effect as the following
two lines combined:
pmnc.execute.on("next_cage_queue").next_module.next_method(*args, **kwargs)
raise DontProceedAnyFurther()
Notice, that the execution of target_method will terminate upon pmnc_chain.next
although the resulting exception is masked and not propagated. For the same
reason you should never do anything like this
try:
pmnc_chain.next(...)
except:
pass
Think SystemExit.
|
Features Download Documentation Tutorial |