I'm working on building a custom tool (using Python SDK, if that's relevant). My use case uses multiple IncomingInterfaces. What I can't figure out if there is a way to know which of the incoming interfaces will be processed first, or if we can rely on all of the records from one IncomingInterface being processed before another interface is processed, or... really if there are any guarantees in the operation order and any way to manipulate and control them.
To provide some more context, this tool has one optional input interface that could contain some configuration for the tool itself (it would override anything set in the GUI of the tool). Right now I'm not able to be sure that the record with the config comes in before records from the one required interface are processed, which means the tool might not do the right thing.
Any definitive answers (even if the answer is that the order is non-deterministic) would be very helpful!
Solved! Go to Solution.
The short answer is that it is non-deterministic. Details below, and the usual workaround at the end.
The order that you receive ii_add_incoming_connection calls is essentially non-deterministic. Similarly, the order in which ii_push_record is called on each of your inputs is non-deterministic. It will depend on what the upstream tools do and how they are configured--so within a particular workflow it may appear deterministic, but it is not deterministic across all workflows.
So in some workflows you might receive ii_add_incoming_connection calls for each of your inputs before ii_push_record is ever called for any of them, and in some workflows one input might call ii_add_incoming_connection, a series of ii_push_records, and then ii_close before the other input is ever added. An example of where we might do the former would be two input tools--one input tool might open, pump all its records, then close, then the other input tool would do the same. An example of where the other might happen would be if your two inputs were the two outputs of a filter tool, where the ii_add_incoming_connections would happen about the same time, the ii_push_records would come in an arbitrary order on either input, and they would both close at about the same time.
Typically if records from one input require information from the other input before they can be processed you have to cache them somewhere and then pull them out once ii_close has been called on each of the relevant inputs.
Thanks for the input! Very helpful!