Skip to content

Get path at process_request #28

@gokh4n

Description

@gokh4n

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.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions