So, I’m writing a python web application using the twisted web2 framework. There’s a library that I need to use (SQLAlchemy, to be specific) that doesn’t have asynchronous code. Would it be bad to spawn a thread to handle the request, fetch any data from the DB, and then return a response? I’m afraid that if there was a flood of requests, too many threads would be started and the server would be overwhelmed. Is there something built into twisted that prevents this from happening (eg request throttling)?
So, I’m writing a python web application using the twisted web2 framework. There’s a
Share
See the docs, and specifically the thread pool which lets you control how many threads are active at most. Spawning one new thread per request would definitely be an inferior idea!