Пример #1
0
def ping_master(request):
    stamp = timezone.now()
    Master.send_ping()
    pong = False
    count = 0
    while not pong and count < 5:
        found = Message.objects.filter(type=log.LOG_TYPE_TEXT[log.INFO], timestamp__gt=stamp, text=MessagePong)
        if len(found) > 0:
            pong = True
        else:
            time.sleep(1)
            count += 1
    if pong:
        return HttpResponse(MessagePong)
    return HttpResponse('No reply from master')
Пример #2
0
def ping_master(request):
    stamp = timezone.now()
    Master.send_ping()
    pong = False
    count = 0
    while not pong and count < 5:
        found = Message.objects.filter(type=log.LOG_TYPE_TEXT[log.INFO],
                                       timestamp__gt=stamp,
                                       text=MessagePong)
        if len(found) > 0:
            pong = True
        else:
            time.sleep(1)
            count += 1
    if pong:
        return HttpResponse(MessagePong)
    return HttpResponse('No reply from master')