ronrothman / mtwsgi Goto Github PK
View Code? Open in Web Editor NEWA Multithreaded Python WSGI Implementation
License: MIT License
A Multithreaded Python WSGI Implementation
License: MIT License
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 request stage. 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, threads=None, *args, **kwargs):
WSGIServer.__init__(self, *args, **kwargs)
self.threads = threads
self.pool = multiprocessing.pool.ThreadPool(2)
self.pool2 = multiprocessing.pool.ThreadPool(2)
def process_request_thread(self, r, client_address):
try:
self.finish_request(r, client_address)
self.shutdown_request(r)
except:
self.handle_error(r, client_address)
self.shutdown_request(r)
def process_request(self, r, client_address):
path = str(r.makefile('rb', -1).readline(65537), 'iso-8859-1').rstrip('\r\n').split()[1]
if path == '/Add' or path == '/Delete':
self.pool.apply_async(self.process_request_thread, args=(r, client_address))
else:
self.pool2.apply_async(self.process_request_thread, args=(r, client_address))
2. Problem - I want to set different timeout value of request by paths.
3. Answer - I setted 4 threads. I run code. Result 7 threads opened. Why?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.