You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
I'm running my tests in parallel using 4 processes - scenario by scenario.
Now I want to do some tasks in before_all and after_all but only 1 time, meaning do X in before_all only 1 time and use X in after_all only 1 time
What I tried
I tried to use context.config.userdata['worker_id'], current_process(), parent_process() in order to identify but instances are totally differet.
Please suggest me some solution or a workaround which I can try to achieve it
Thanks
The text was updated successfully, but these errors were encountered:
prashant1507
changed the title
Not able to execute before_all and after_all method only once
[Help Needed] Not able to execute before_all and after_all method only once
Nov 1, 2024
Hi! A couple workarounds I can think of (depending on what it is you wanna do):
if you dont need the access to context, perhaps consider doing that one thing before and after the behavex process. e.g. run a python script that does that one thing before launching behavex, then another one after. Then perhaps you can chain these scripts with various ways like via cli or makefile for instance.
if you need access to context, try to see if creating a temporary file helps. so, check if the file exists -> create if not -> do the thing. i think you'll still get race conditions using this approach but worth trying.
watching the issue to keep an eye out for other inputs!
Hi @prashant1507, having before_all and after_all being executed only once is not possible by design. As "context" variables are not shared through the different parallel processes, the before_all and after_all hooks need to be executed in each parallel session.
However, it might be possible to provide a new hook (something like behavex_before_all/behavex_after_all) that is executed only once pero parallel run. The limitation will be that the "context" variables will not be available as part of this hook, due to there is no easy way to replicate complex objects across parallel processes (only primitive values).
I'm setting this as an enhancement.
Description
I'm running my tests in parallel using 4 processes - scenario by scenario.
Now I want to do some tasks in before_all and after_all but only 1 time, meaning do X in before_all only 1 time and use X in after_all only 1 time
What I tried
I tried to use
context.config.userdata['worker_id']
, current_process(), parent_process() in order to identify but instances are totally differet.Please suggest me some solution or a workaround which I can try to achieve it
Thanks
The text was updated successfully, but these errors were encountered: