

def _queue(self):
    try:
        obj = self.get_queryset()[0]
    except:
        obj = False
    if (not obj):
        while True:
            msg = 'compatibility: true\n'
            msg += 'retry: 10000\n'
            msg += 'data: {0}\n\n'.format(json.dumps({
                'action': 'error',
            }))
            (yield msg)
            time.sleep(10)
    else:
        while True:
            pubsub = self._db(obj)
            for m in pubsub.listen():
                if (m['type'] == 'message'):
                    msg = 'compatibility: true\n'
                    msg += 'retry: 10000\n'
                    msg += 'data: {0}\n\n'.format(m['data'])
                    (yield msg)
            ping = 'compatibility: true\n'
            ping += 'retry: 10000\n'
            ping += 'data: {0}\n\n'.format(json.dumps({
                'action': 'ping',
            }))
            (yield ping)
            time.sleep(0.5)

dataset/ETHPy150Open opps/opps/opps/contrib/notifications/views.py AsyncServer._queue/original