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
Hello,
Firstly, the code worked very well, thank you for that. I have some problems. I'd appreciate it if you could help.
1. Problem - I want to get path at the process_request. Define two separate thread pools and i want to add requests to the thread pool by paths. I can get path, but the request is terminated. My sample code is below.
def __init__(self, nworkers, daemon=False, **threadpool_options):
self.running = True
assert nworkers > 0, "ThreadPoolMixIn servers must have at least one worker"
self.thread_pool = ThreadPool(
nworkers,
"ThreadPoolMixIn HTTP server on %s:%d"
% (self.server_name, self.server_port),
daemon,
**threadpool_options)
def process_request(self, request, client_address):
request.setblocking(1)
path = str(request.makefile('rb', -1).readline(65537), 'iso-8859-1').rstrip('\r\n').split()[1]
self.thread_pool.add_task(
lambda: self.process_request_in_thread(request, client_address))
2. Problem - I want to set different timeout value of request by paths.
I'm having a little trouble trying to understand what you are trying to do, but if you are trying to get the URL of the request the request.script_name and request.path_info may help, assuming that request is a WSGIRequest object from paste.wsgiwrappers.
If you're able to explain more about what are you trying to do, I may be able to provide more information but also keep in mind the warning from the top of the readme: "please consider using other options".
Thanks you for your answer. I can try to get request.path_info in process_request function. Because i have two thread pools. I want to add task in thread pool by request path. But i cant do it.
Activity
[-]Get path at the beginning of request[/-][+]Get path at before request[/+][-]Get path at before request[/-][+]Get path at process_request[/+]cdent commentedon Aug 3, 2019
I'm having a little trouble trying to understand what you are trying to do, but if you are trying to get the URL of the request the
request.script_nameandrequest.path_infomay help, assuming thatrequestis aWSGIRequestobject frompaste.wsgiwrappers.If you're able to explain more about what are you trying to do, I may be able to provide more information but also keep in mind the warning from the top of the readme: "please consider using other options".
gokh4n commentedon Aug 4, 2019
Thanks you for your answer. I can try to get request.path_info in process_request function. Because i have two thread pools. I want to add task in thread pool by request path. But i cant do it.