<commit_before>from django.http import HttpResponse, HttpResponseServerError, JsonResponse
from tasks import faceSwapTask

def startSwap(request):
	imageb64 = request.POST.get("imageb64", None)
	if imageb64 is None:
		return HttpResponseServerError()

	result = faceSwapTask.delay(imageb64)

	return HttpResponse(result.id, content_type="text/plain")

def getSwap(request):
	taskId = request.GET.get("taskId", None)

	reply = {}

	if taskId:
		#get the results from celery
		result = faceSwapTask.AsyncResult(taskId)
		reply["status"] = result.status

		#if the task has finished
		if reply["status"] == "SUCCESS":
			#get the image
			reply["image"] = result.get()
			#if no image has been returned (probably no faces)
			if reply["image"] is None:<commit_msg>don't bother processing image after 3minutes has passed<commit_after>from django.http import HttpResponse, HttpResponseServerError, JsonResponse
from tasks import faceSwapTask

def startSwap(request):
	imageb64 = request.POST.get("imageb64", None)
	if imageb64 is None:
		return HttpResponseServerError()

	#send an image to be processed, but ignore the task if its taking longer than 3 minutes
	result = faceSwapTask.apply_async((imageb64,), expires=60*3)

	return HttpResponse(result.id, content_type="text/plain")

def getSwap(request):
	taskId = request.GET.get("taskId", None)

	reply = {}

	if taskId:
		#get the results from celery
		result = faceSwapTask.AsyncResult(taskId)
		reply["status"] = result.status

		#if the task has finished
		if reply["status"] == "SUCCESS":
			#get the image
			reply["image"] = result.get()
			#if no image has been returned (probably no faces)
			if reply["image"] is None:
{'fraction_non_alphanumeric': 0.10680190930787589, 'fraction_numerical': 0.012529832935560859, 'mean_word_length': 5.010752688172043, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5790019', 'n_tokens_mistral': 570, 'n_tokens_neox': 513, 'n_words': 162}