You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import global_data # A file to store master PID
workers = 1
worker_class = "uvicorn.workers.UvicornWorker"
bind = "127.0.0.1:8111"
timeout = 86400
graceful_timeout = 86400
max_requests = 1
def when_ready(server):
print(f"Master ID is {server.pid}")
global_data.server_id = server.pid
def pre_request(worker, req):
worker.log.debug("%s %s", req.method, req.path)
print(req.method, req.path)
if global_data.server_id is None:
raise ValueError("Incorrect Master Process ID")
print("Inside method !")
print(worker)
os.system(f"kill -TTIN {global_data.server_id}")
def post_request(worker, req, environ, resp):
print(req.method, req.path)
print(resp)
print(worker)
print(environ)
def worker_abort(worker):
print("Worker shutdown !")
After I send a request using Postman, I get none of the print statements in the server hooks pre_request and post_request.
My objective is to initialize one worker for each request, and then kill the worker after completing the process. This is to avoid/minimise the memory leak.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have the following configuration:
After I send a request using Postman, I get none of the print statements in the server hooks
pre_request
andpost_request
.My objective is to initialize one worker for each request, and then kill the worker after completing the process. This is to avoid/minimise the memory leak.
Beta Was this translation helpful? Give feedback.
All reactions