Skip to content

Commit 6430357

Browse files
committed
gc.collect after run
1 parent 12e3395 commit 6430357

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

timeside/server/models.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import mimetypes
3030
import ast
3131
import time
32+
import gc
3233
from shutil import copyfile
3334

3435
import timeside.core
@@ -398,9 +399,23 @@ def set_results_from_processor(proc, preset=None):
398399
result.mime_type_setter(get_mime_type(result.file.path))
399400
result.status_setter(_DONE)
400401

402+
if hasattr(proc, 'values'):
403+
proc.values = None
404+
del proc.values
405+
if hasattr(proc, 'result'):
406+
proc.result = None
407+
del proc.result
408+
if hasattr(proc, 'results'):
409+
try:
410+
proc.results = None
411+
del proc.results
412+
except:
413+
continue
401414
del proc
402415

403416
del pipe
417+
gc.collect()
418+
404419
# item.lock_setter(False)
405420

406421

timeside/server/tasks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import
22

33
import time
4+
import gc
45

56
from celery import shared_task
67
from celery.result import AsyncResult
@@ -31,7 +32,7 @@ def experience_run(exp_id, item_id):
3132
item = Item.objects.get(id=item_id)
3233
experience = Experience.objects.get(id=exp_id)
3334
item.run(experience)
34-
35+
gc.collect()
3536

3637
@shared_task
3738
def task_monitor(task_id, results_id):

0 commit comments

Comments
 (0)