Achieving RF *keyword* concurrency with Python

274 views
Skip to first unread message

komodospider

unread,
Mar 30, 2015, 7:21:03 AM3/30/15
to robotframe...@googlegroups.com
Hi,
Since RF does not provide (test or) keyword concurrency out of the box, I thought to write a little module that will accept a keyword and execute it a set number of times. This however does not work as I had expected with the keyword being called sequentially. Here is the python snippet that I use.

def kw(keyword, num_times, workers=10):
with concurrent.futures.ProcessPoolExecutor(workers) as executor:
for _ in range (0, num_times):
executor.submit(BuiltIn().run_keyword(keyword))

So what 'kw' is expected to do is to call this keyword a 'num_times' concurrently. However the result is purely sequential. Note that I'm only trying to run a certain keyword multiple concurrent times within one robot test.  Any ideas?

The alternatives that I can see ofc are to 
1. From RF call python and let Python run the intended function concurrently. The drawback for me is that the keyword that is already implemented in RF will need to be reimplemented in python.
2. From RF call python, then let python call the RF test with pybot concurrently.

But can I accomplish what I am trying to achieve with my original thought?

Thanks.

komodospider

unread,
Mar 31, 2015, 11:36:12 AM3/31/15
to robotframe...@googlegroups.com
I found this: https://github.com/Chetic/robotframework-async/tree/master/AsyncLibrary
Have not tried it myself yet. Just for anyone else looking :)

Markus Bernhardt

unread,
Mar 31, 2015, 11:41:06 AM3/31/15
to sbk...@gmail.com, robotframe...@googlegroups.com
Perhaps I'm completely wrong, but I believe multi-threading robotframework is a no-go. I have almost no knowledge about python, but when I ported the selenium2library from python to java I saw a lot code, which is not thread safe. So, even when you manage to execute keywords in parallel, the keyordws will run havoc.

I believe the way to go is to run robotframwork itself multiple times (pabot.py).

Cheers,
Markus

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Tatu Aalto

unread,
Mar 31, 2015, 11:53:50 AM3/31/15
to Markus Bernhardt, robotframework-users, sbk...@gmail.com

Ugh

Threads are possible, but not in way you want and (as always with threads) you must be extra careful or you shoot your self in the foot. Using threads in Robot Framework is explained in the user guide [1].

And what Markus did say, is also true. It depends on your requirements, should you use threads, pabot or both. I am using both but I choose very careful which one to use in which case.

-Tatu
Send from my mobile
[1] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#communication-when-using-threads

Tatu Aalto

unread,
Mar 31, 2015, 11:56:45 AM3/31/15
to Markus Bernhardt, komodospider, robotframework-users
Reply all
Reply to author
Forward
0 new messages