I’m currently writing a rather involved testing framework utilizing Robot. One of our requirements is parellelisation of keywords, and it seems like eg. the Browser library does what we need with its “Promise To” keyword that pushes kw executions into a background thread pool. I am currently following their pattern in the implementation.
Question is, what if some of my keywords call back into Robot’s API? On the Internet it seems quite clear in posts from way back that RF is not thread safe. Has RF recently become thread-safe or does the Browser library (or other parallelism-keyword libs) just assume you’re not calling back into Robot from those parallelized keywords?
RF is not multi-threaded / thread-safe. This has multiple reasons, one being that each keyword entry / exit is registered in the output.xml. If execution becomes async, the integrity of the xml can no longer be ensures (meaning you blow up the logs).
So if you want to do async / multi-threaded stuff, you’d have to write your own keywords and you’d have to ensure the threads are joined before returning from your custom keywords.
For the reasons above, callbacks are not supported.
Yet, some very common libraries (Browser) do something very similar to what I’m trying to build. I am trying to understand the conditions under which they operate.
They build own keywords, and as a Promise (python Future) is returned from the keyword to be waited on, a thread is not joined prior to returning from a keyword. So I take this is doable. But my next question is whether I can call robot’s own API from the waited-on thread – I have not found an example of this yet, and I suspect it’s dangerous.
Dunno how browser handles its things but if you use async within your python library - using those can be handled pretty easily. It could considered as just a bit more fancier state handling within your library.
Calling into built in robot functionality is probably “case by case” - certain calls can alter the state - speficically if using 3rd party libraries and those can lead to issues with threading/async code but i’d guess certain things will just work if your threading / async handling is properly done.