Python Agents in Real-Time Workflows

This section describes how to configure the Python agents in real-time workflows.

The following general information applies:

  • Threading Model
    In real-time workflows you may have several threads running in parallel. When routing a UDR to the Python collection or processing agent, the threading context is kept, which means that when using synchronous routes, the same thread that routed the UDR into the agent, will also route it out to the next agent. It also means that many threads may potentially be created in the Python Interpreter, one per defined workflow thread. You are recommended to use locks and mutexes available in the Python standard threading library to avoid threading issues.

  • Garbage Collection
    A UDR that is routed to a Python agent is kept in both the Python and Java heaps as long as it is referenced. When the UDR is no longer referenced in Python, an automatic message is sent to Java saying that it may be released from the Java heap. If you need to route many large UDRs to Python and keep them alive for a longer period of time, a good solution could be to copy the relevant information into a suitable Python structure in order to allow the UDR to be released. If this is not the case, you should not have to take any specific measures in order for garbage collection to work as it should.

  • Timeouts
    You can use timeouts to implement session timeouts or delayed actions. See Function Blocks for Agents in Real-Time Workflows for an example of how to write a timeout function block.