This question has been flagged
1 Reply
4573 Views

I've got some long running scheduled actions set up.

I'm using

config.get("limit_time_cpu") 

and compare it to the current script execution duration on each iteration. This works fine as long as the task is executed automatically by the scheduler, however the limit it reaches when run manually (Settings -> Technical -> Scheduled Actions) is different (=> limit_time_real).


Is there a way get to know whether the script was executed manually or automatically? uid seems to be one possible option but it doesn't feel right to rely on it.

Avatar
Discard
Best Answer

The solution that I see is to check (in cron function) the calling method, for example this way:

import inspect

if inspect.stack()[6][3] == 'method_direct_trigger':
...is manualy
else:
...is automatically

Method  'method_direct_trigger' is called when cron action is manually. Index 6 = frame 6 on stock.


Avatar
Discard