Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
LOFAR2.0
tango
Commits
830949f6
Commit
830949f6
authored
1 year ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Don't break periodic tasks if they raise an exception
parent
55832207
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tangostationcontrol/tangostationcontrol/common/asyncio.py
+9
-1
9 additions, 1 deletion
tangostationcontrol/tangostationcontrol/common/asyncio.py
with
9 additions
and
1 deletion
tangostationcontrol/tangostationcontrol/common/asyncio.py
+
9
−
1
View file @
830949f6
...
@@ -2,11 +2,14 @@
...
@@ -2,11 +2,14 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
import
asyncio
import
asyncio
import
logging
from
contextlib
import
suppress
from
contextlib
import
suppress
from
concurrent.futures
import
Future
,
CancelledError
from
concurrent.futures
import
Future
,
CancelledError
from
threading
import
Thread
from
threading
import
Thread
from
typing
import
Callable
from
typing
import
Callable
logger
=
logging
.
getLogger
()
class
EventLoopThread
:
class
EventLoopThread
:
"""
A forever running thread that keeps executing the given event_loop.
"""
"""
A forever running thread that keeps executing the given event_loop.
"""
...
@@ -88,7 +91,12 @@ class PeriodicTask:
...
@@ -88,7 +91,12 @@ class PeriodicTask:
async
def
_call_periodically
(
self
):
async
def
_call_periodically
(
self
):
while
not
self
.
done
:
while
not
self
.
done
:
try
:
await
self
.
func
()
await
self
.
func
()
except
(
CancelledError
,
asyncio
.
CancelledError
):
raise
except
Exception
as
ex
:
logger
.
exception
(
f
"
Periodic task
{
self
.
func
}
raised an exception
"
)
# TODO(JDM): Calculate how long to sleep to have the runtime of
# TODO(JDM): Calculate how long to sleep to have the runtime of
# func be subtracted.
# func be subtracted.
...
...
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