Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
engine
Commits
6945acb4
Commit
6945acb4
authored
3 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Proper handling for aborted timers.
#78
parent
847c7ca1
No related branches found
No related tags found
No related merge requests found
Pipeline
#1031
failed
3 years ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/control.py
+17
-7
17 additions, 7 deletions
src/control.py
with
17 additions
and
7 deletions
src/control.py
+
17
−
7
View file @
6945acb4
#
# Aura Engine (https://gitlab.servus.at/aura/engine)
#
# Copyright (C) 2017-
2020
- The Aura Engine Team.
# Copyright (C) 2017-
now()
- The Aura Engine Team.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
...
...
@@ -186,15 +186,15 @@ class EngineExecutor(Timer):
"""
timer_store
:
dict
=
{}
logger
=
logging
.
getLogger
(
"
AuraEngine
"
)
EVENT_ON_READY
=
"
on_ready
"
_lock
=
None
direct_exec
:
bool
=
None
is_aborted
:
bool
=
None
parent_timer
:
Timer
=
None
child_timer
:
Timer
=
None
timer_id
:
str
=
None
timer_type
:
str
=
None
func
=
None
func
:
func
=
None
param
=
None
diff
=
None
dt
=
None
...
...
@@ -222,6 +222,7 @@ class EngineExecutor(Timer):
# Init meta data
self
.
direct_exec
=
False
self
.
is_aborted
=
False
self
.
timer_type
=
timer_type
self
.
timer_id
=
f
"
{
timer_type
}
:
{
func
.
__name__
}
:
{
due_time
}
"
...
...
@@ -236,11 +237,12 @@ class EngineExecutor(Timer):
is_stored
=
self
.
update_store
()
if
not
is_stored
:
self
.
logger
.
info
(
SU
.
red
(
f
"
Timer
'
{
self
.
timer_id
}
'
omitted because it
'
s already existing but dead
"
))
self
.
logger
.
info
(
SU
.
yellow
(
f
"
Timer
'
{
self
.
timer_id
}
'
omitted because it
'
s already existing but dead
"
))
self
.
is_aborted
=
True
else
:
if
diff
<
0
:
msg
=
f
"
Timer
'
{
self
.
timer_id
}
'
is due in the past. Executing immediately ...
"
self
.
logger
.
warn
(
SU
.
yellow
(
msg
))
self
.
logger
.
warn
ing
(
SU
.
yellow
(
msg
))
self
.
exec_now
()
elif
diff
==
0
:
self
.
logger
.
debug
(
f
"
Timer
'
{
self
.
timer_id
}
'
to be executed immediately
"
)
...
...
@@ -274,7 +276,6 @@ class EngineExecutor(Timer):
self
.
direct_exec
=
True
self
.
wait_for_parent
()
thread
=
Thread
(
name
=
self
.
timer_id
,
target
=
self
.
func
,
args
=
(
self
.
param
,))
time
.
sleep
(
0.2
)
thread
.
start
()
...
...
@@ -293,7 +294,6 @@ class EngineExecutor(Timer):
else
:
self
.
func
()
super
().
__init__
(
self
.
diff
,
wrapper_func
,
(
self
.
param
,))
self
.
_name
=
self
.
timer_id
time
.
sleep
(
0.2
)
self
.
start
()
...
...
@@ -342,6 +342,8 @@ class EngineExecutor(Timer):
"""
if
self
.
direct_exec
==
True
:
return
False
if
self
.
is_aborted
==
True
:
return
False
return
super
().
is_alive
()
...
...
@@ -370,6 +372,14 @@ class EngineExecutor(Timer):
del
EngineExecutor
.
timer_store
[
timer_id
]
@staticmethod
def
command_history
():
"""
Returns a list of recent active and inactive timers to the logger.
"""
return
EngineExecutor
.
timer_store
.
values
()
@staticmethod
def
log_commands
():
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment