def post(self, request): if request.is_ajax(): id = request.POST.get('id', None) try: log_object = Log.objects.get(id=id) queue = get_redis_instance() queue.pubsub() queue.publish(log_object.channel, '10.disconnect;') log_object.end_time = now() log_object.is_finished = True log_object.save() return JsonResponse({ 'status': True, 'message': 'Session has been killed !' }) except ObjectDoesNotExist: return JsonResponse({ 'status': True, 'message': 'Request object does not exist!' }) except Exception, e: log_object = Log.objects.get(id=id) log_object.end_time = now() log_object.is_finished = True log_object.save() return JsonResponse({'status': False, 'message': str(e)})
def queue(self): queue = get_redis_instance() channel = queue.pubsub() return queue