/api/debug/running has audiogens

This commit is contained in:
boyska 2015-02-01 00:08:56 +01:00
parent 24cda62c5f
commit 785a2c78fe
No known key found for this signature in database
GPG key ID: 7395DCAE58289CA9
2 changed files with 23 additions and 2 deletions

View file

@ -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)

View file

@ -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):