Skip to content
Snippets Groups Projects
Commit 9c7bbbdd authored by Julian Rother's avatar Julian Rother
Browse files

Send notifications for exceptions in scheduled functions

parent 7b9d3142
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,8 @@ def sched_func(delay, priority=0, firstdelay=None, args=[], kargs={}):
func(*args, **kargs)
except Exception:
traceback.print_exc()
notify_admins('scheduler_exception', name=func.__name__,
traceback=traceback.format_exc())
scheduler.enter(delay, priority, sched_wrapper)
scheduler.enter(firstdelay, priority, sched_wrapper)
print("Scheduler: registered {} (frequency 1/{}s, start delay: {}s)".format(func.__name__, delay, firstdelay))
......
......@@ -43,10 +43,10 @@ if not config.get('SECRET_KEY', None):
config['SECRET_KEY'] = os.urandom(24)
from db import query, modify, show, searchquery
from mail import notify_mods, notify_admins
from ldap import ldapauth
from legacy import legacy_index
from scheduler import sched_func
from mail import notify_mods, notify_admins
mod_endpoints = []
......@@ -124,7 +124,7 @@ def handle_not_found(e=None):
@app.errorhandler(Exception)
def handle_internal_error(e):
traceback.print_exc()
notify_admins('exception', traceback=traceback.format_exc())
notify_admins('endpoint_exception', traceback=traceback.format_exc())
return render_template('500.html'), 500
@sched_func(5*60, firstdelay=0)
......
Function: {{ name }}
Hostname: {{ gethostname() }}
{{ traceback }}
Exception in scheduler function "{{ name }}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment