Add examples for timer

This commit is contained in:
Mauricio Baeza 2021-06-21 22:47:39 -05:00
parent abfab3d254
commit 7a58bb695b
1 changed files with 44 additions and 0 deletions

View File

@ -393,3 +393,47 @@ Call command line and capture output line by line.
21/06/2021 22:34:42 - DEBUG - drwxr-xr-x 13 mau mau 4.0K Jun 21 15:34 Projects
21/06/2021 22:34:42 - DEBUG - drwxr-xr-x 2 mau mau 4.0K May 11 18:48 Templates
21/06/2021 22:34:42 - DEBUG - drwxr-xr-x 2 mau mau 4.0K Jun 20 23:27 Videos
Timer
^^^^^
Execute any macro every seconds.
.. code-block:: python
TIMER_NAME = 'clock'
def show_time():
app.debug(app.now(True))
return
def start_clock():
seconds = 1
macro = {
'library': 'test',
'name': 'show_time',
}
app.start_timer(TIMER_NAME, seconds, macro)
return
def stop_clock():
app.stop_timer(TIMER_NAME)
return
def main(args=None):
start_clock()
return
Execute `stop_clock` for stop timer.
.. code-block:: bash
21/06/2021 22:43:17 - INFO - Timer started... show_time
21/06/2021 22:43:18 - DEBUG - 22:43:18.080315
21/06/2021 22:43:19 - DEBUG - 22:43:19.082211
...
21/06/2021 22:43:46 - DEBUG - 22:43:46.126446
21/06/2021 22:43:47 - DEBUG - 22:43:47.128487
21/06/2021 22:43:47 - INFO - Timer stopped... show_time