From 785a2c78fee5b2eaae4772ecdd5b86d263116d06 Mon Sep 17 00:00:00 2001 From: boyska Date: Sun, 1 Feb 2015 00:08:56 +0100 Subject: [PATCH] /api/debug/running has audiogens --- larigira/event.py | 7 ++++++- larigira/rpc.py | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/larigira/event.py b/larigira/event.py index 4b53dae..d8258ac 100644 --- a/larigira/event.py +++ b/larigira/event.py @@ -106,7 +106,12 @@ class Monitor(ParentedLet): audiogen = gevent.spawn_later(delta.total_seconds(), audiogenerate, audiospec) - self.running[timespec.eid] = audiogen + self.running[timespec.eid] = { + 'greenlet': audiogen, + 'running_time': datetime.now() + timedelta( + seconds=delta.total_seconds()), + 'audiospec': audiospec + } gevent.spawn_later(delta.total_seconds(), self.source.reload_id, timespec.eid) diff --git a/larigira/rpc.py b/larigira/rpc.py index f1ca992..d8fe03c 100644 --- a/larigira/rpc.py +++ b/larigira/rpc.py @@ -34,6 +34,20 @@ def rpc_refresh(): return jsonify(dict(status='ok')) +def get_scheduled_audiogen(): + larigira = current_app.larigira + model = larigira.monitor.source.model + running = larigira.monitor.running + events = {t: {} for t in running.keys()} + for timespec_eid in events: + orig_info = running[timespec_eid] + info = events[timespec_eid] + info['running_time'] = orig_info['running_time'].isoformat() + info['audiospec'] = orig_info['audiospec'] + info['timespec'] = model.get_alarm_by_id(timespec_eid) + return events + + @rpc.route('/debug/running') def rpc_wip(): greenlets = [] @@ -44,7 +58,9 @@ def rpc_wip(): 'class': ob.__class__.__name__, 'parent': repr(ob.parent) }) - return jsonify(dict(greenlets=greenlets)) + return jsonify(dict(greenlets=greenlets, + audiogens=get_scheduled_audiogen(), + )) def create_app(queue, larigira):