I need to generate a job-id for user-request call which I thought of handling it through python-theading using below block:
from flask_restful import Resource
from flask import copy_current_request_context
import uuid
import time
class ScoreReportGenerator:
def trigger_job():
try:
# Do memory-intensive process
return "success"
except:
return "failure"
class JobSubmitter(Resource):
def post(self):
job_id = uuid.uuid4()
@copy_current_request_context
def start_score_report_generator_thread(payload_data, job_id):
score_report_generator = ScoreReportGenerator()
score_report_generator.trigger_job()
t = threading.Thread(target=start_score_report_generator_thread, args=[payload_data, job_id])
t.setDaemon(False)
t.start()
response = dict()
response["status"] = "RUNNING"
response["jobId"] = str(job_id)
return response
Here what had been noticed, around 70GB of RAM is occuppied by this spawned thread, after completion of thread 70GB of RAM remains occupied. After killing the whole python application, RAM is getting released.
Looking forward for suggestions to release RAM-Memory consumption, any help welcomed!
Thanks in advance!