Don't fire async event inside an already async event

This commit is contained in:
Ruud
2014-01-11 20:46:01 +01:00
parent f0b096d41a
commit bf2beb2530

View File

@@ -28,9 +28,12 @@ class MediaBase(Plugin):
def onComplete():
db = get_session()
media = db.query(Media).filter_by(id = id).first()
fireEventAsync('%s.searcher.single' % media.type, media.to_dict(self.default_dict), on_complete = self.createNotifyFront(id))
media_dict = media.to_dict(self.default_dict)
event_name = '%s.searcher.single' % media.type
db.expire_all()
fireEvent(event_name, media_dict, on_complete = self.createNotifyFront(id))
return onComplete
def createNotifyFront(self, media_id):
@@ -38,7 +41,10 @@ class MediaBase(Plugin):
def notifyFront():
db = get_session()
media = db.query(Media).filter_by(id = media_id).first()
fireEvent('notify.frontend', type = '%s.update' % media.type, data = media.to_dict(self.default_dict))
media_dict = media.to_dict(self.default_dict)
event_name = '%s.update' % media.type
db.expire_all()
fireEvent('notify.frontend', type = event_name, data = media_dict)
return notifyFront