Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Postal Owl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
Postal Owl
Commits
4350dace
Commit
4350dace
authored
9 months ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
E-mail administrator when a background action crashes
Closes #109.
parent
9a5722a6
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
owl/__init__.py
+15
-8
15 additions, 8 deletions
owl/__init__.py
with
15 additions
and
8 deletions
owl/__init__.py
+
15
−
8
View file @
4350dace
...
...
@@ -8,7 +8,9 @@ import logging
import
os
from
sqlalchemy
import
select
from
sqlalchemy.orm
import
joinedload
import
sys
import
tempfile
from
typing
import
Callable
import
werkzeug.exceptions
import
owl.assets
as
assets
...
...
@@ -291,19 +293,26 @@ try:
# asynchronous evaluation. Each mule is notified by signals, but it wakes
# up and scans its queue occasionally in case a signal was lost.
def
background_action
(
handler
:
Callable
[[],
None
])
->
None
:
try
:
with
app
.
app_context
():
handler
()
except
Exception
as
e
:
exc_info
=
sys
.
exc_info
()
app
.
logger
.
error
(
'
Error when processing background action: %s
'
,
e
,
exc_info
=
exc_info
)
owl
.
error_mail
.
log_exception
(
app
,
'
background
'
,
{},
exc_info
)
# Mule 1
@timer
(
300
,
target
=
'
mule1
'
)
def
mule1_timer
(
signum
):
app
.
logger
.
debug
(
'
Mule 1: Received timer tick
'
)
with
app
.
app_context
():
owl
.
notify
.
send_notify
()
background_action
(
owl
.
notify
.
send_notify
)
@signal
(
42
,
target
=
'
mule1
'
)
def
mule1_signal
(
signum
):
app
.
logger
.
debug
(
'
Mule 1: Received signal
'
)
with
app
.
app_context
():
owl
.
notify
.
send_notify
()
background_action
(
owl
.
notify
.
send_notify
)
def
wake_up_notify_mule
():
app
.
logger
.
debug
(
'
Mule 1: Sending wakeup signal
'
)
...
...
@@ -314,14 +323,12 @@ try:
@timer
(
300
,
target
=
'
mule2
'
)
def
mule2_timer
(
signum
):
app
.
logger
.
debug
(
'
Mule 2: Received timer tick
'
)
with
app
.
app_context
():
owl
.
auto_eval
.
process_queue
()
background_action
(
owl
.
auto_eval
.
process_queue
)
@signal
(
43
,
target
=
'
mule2
'
)
def
mule2_signal
(
signum
):
app
.
logger
.
debug
(
'
Mule 2: Received signal
'
)
with
app
.
app_context
():
owl
.
auto_eval
.
process_queue
()
background_action
(
owl
.
auto_eval
.
process_queue
)
def
wake_up_eval_mule
():
app
.
logger
.
debug
(
'
Mule 2: Sending wakeup signal
'
)
...
...
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