Esempio n. 1
0
    def _queue(self):
        try:
            redis = Db('eventadmindetail', self.get_object().id)
        except:
            redis = Db('eventadmindetail', self.event_obj.id)
        pubsub = redis.object().pubsub()
        pubsub.subscribe(redis.key)

        for conn in connections.all():
            conn.close()

        while True:
            for m in pubsub.listen():
                if m['type'] == 'message':
                    msg = u"compatibility: true\n"
                    msg += u"retry: 10000\n"
                    msg += u"data: {}\n\n".format(m['data'])
                    yield msg

                stream = u"compatibility: true\n"
                stream += u"retry: 10000\n"
                stream += u"data: {}\n\n".format(
                    json.dumps({"event": "stream"}))
                yield stream
            time.sleep(0.5)
Esempio n. 2
0
    def _queue(self):
        try:
            redis = Db('eventadmindetail', self.get_object().id)
        except:
            redis = Db('eventadmindetail', self.event_obj.id)
        pubsub = redis.object().pubsub()
        pubsub.subscribe(redis.key)

        for conn in connections.all():
            conn.close()

        while True:
            for m in pubsub.listen():
                if m['type'] == 'message':
                    msg  = u"compatibility: true\n"
                    msg += u"retry: 10000\n"
                    msg += u"data: {}\n\n".format(m['data'])
                    yield msg

                stream  = u"compatibility: true\n"
                stream += u"retry: 10000\n"
                stream += u"data: {}\n\n".format(
                    json.dumps({"event": "stream"}))
                yield stream
            time.sleep(0.5)
Esempio n. 3
0
 def _db(self, obj):
     _db = Db(
         obj.container.get_absolute_url(),
         obj.container.id)
     pubsub = _db.object().pubsub()
     pubsub.subscribe(_db.key)
     return pubsub
Esempio n. 4
0
    def test_pubsub_notification(self):
        noti = Notification.objects.all()[0]
        _db = Db(noti.container.get_absolute_url(),
                 noti.container.id)
        pubsub = _db.object().pubsub()
        pubsub.subscribe(_db.key)

        self.assertTrue(pubsub)
Esempio n. 5
0
    def test_pubsub_notification(self):
        noti = Notification.objects.all()[0]
        _db = Db(noti.container.get_absolute_url(), noti.container.id)
        pubsub = _db.object().pubsub()
        pubsub.subscribe(_db.key)

        self.assertTrue(pubsub)
        self.assertEqual(pubsub.channels, set([u'opps_/home/test.html_1']))
Esempio n. 6
0
    def test_pubsub_notification(self):
        noti = Notification.objects.all()[0]
        _db = Db(noti.container.get_absolute_url(),
                 noti.container.id)
        pubsub = _db.object().pubsub()
        pubsub.subscribe(_db.key)

        self.assertTrue(pubsub)
        self.assertEqual(pubsub.channels,
                         set([u'opps_/home/test.html_1']))
Esempio n. 7
0
 def _sse_queue():
     redis = Db('goalservematch', match_pk)
     pubsub = redis.object().pubsub()
     pubsub.subscribe(redis.key)
     while True:
         for m in pubsub.listen():
             if m['type'] == 'message':
                 data = m['data'].decode('utf-8')
                 yield u"data: {}\n\n".format(data)
         yield
         time.sleep(0.5)
Esempio n. 8
0
    def _queue(self):
        redis = Db('eventadmindetail', self.get_object().id)
        pubsub = redis.object().pubsub()
        pubsub.subscribe(redis.key)

        while True:
            for m in pubsub.listen():
                if m['type'] == 'message':
                    data = m['data'].decode('utf-8')
                    yield u"data: {}\n\n".format(data)
            yield
            time.sleep(0.5)
Esempio n. 9
0
 def _db(self, obj):
     _db = Db(obj.container.get_absolute_url(), obj.container.id)
     pubsub = _db.object().pubsub()
     pubsub.subscribe(_db.key)
     return pubsub