- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
In most cases, your function will be executed concurrently inside of your Node, once per received message.
If you need to protect certain sections of your function from concurrent execution, you may use the Context object itself as a Python Lock object.
For example, using a processor
function:
def processor(*, context, message, source, **kwargs):
with context:
# perform non-concurrent code here
return message
NOTE - always make sure that you release the lock prior to exiting your function or your Node will stop processing messages!! The best way to do this is shown above by using a Python
with
clause.
This is generally necessary when you decide that you wish to add additional attributes to the Context object.