Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2@file
3@brief Repeat execution.
4"""
7def repeat_script(script, every_second=20, stop_after_second=-1,
8 outfile='out.log', errfile='err.log',
9 exc=True, verbose=1, fLOG=print):
10 """
11 Runs a python script on a regular basis. The function
12 is not multithreaded, it returns when all execution
13 are done.
15 :param script: script to run
16 :param every_second: every second
17 :param stop_after_second: stop after a given time or never if -1
18 :param outfile: file which receives the standard output
19 :param errfile: file which receives the standard error
20 :param exc: True to stop if an exception is raised, False to continue
21 :param verbose: prints out every execution
22 :param fLOG: logging function
24 .. cmdref::
25 :title: Repeat script execution every n seconds
26 :cmd: -m pyquickhelper repeat_script --help
28 The command line runs the execution a script
29 on a regular basis.
30 """
31 from ..loghelper.time_helper import repeat_script_execution
33 every_second = int(every_second)
34 stop_after_second = int(stop_after_second)
35 if stop_after_second == -1:
36 stop_after_second = None
37 exc = exc in ('1', 1, 'True', 'true', True)
39 repeat_script_execution(script, every_second=every_second,
40 stop_after_second=stop_after_second,
41 outfile=outfile, errfile=errfile,
42 verbose=1, fLOG=fLOG, exc=exc)