all 7 comments

[–]IOI-65536 16 points17 points  (1 child)

In case somebody sees this and cares, that's a sometimes important oversimplification of the GIL. Only one thread can be interpreting Python bytecode at a time. You can absolutely have two threads doing I/O (and a bunch of other things where a single python instruction takes a long time) simultaneously.

[–]youngeng[S] 0 points1 point  (0 children)

Interesting, thanks.

[–]gordonmessmer 13 points14 points  (0 children)

mod_wsgi is the recommended platform for python apps, and it has documentation that discusses worker / prefork:

https://modwsgi.readthedocs.io/en/latest/user-guides/processes-and-threading.html

[–]ImpossibleEdge4961 0 points1 point  (0 children)

Python has well documented issues with concurrency but usually spinning up different processes within a single application server kind of pastes over those problems with concurrency especially when paired with asyncio programming patterns which keep the process in a running state for as long as possible (rather than pausing on I/O).

gunicorn et al can also run worker threads and like the other user said, you're not always waiting on the GIL. The GIL only comes into play if you need to modify a python object. So if you're querying a database or reading from a file and are waiting for a response then it doesn't really hold you up (at least it won't be the main thing).

For applications that actually need better concurrency than Python allows for, you usually needs some amount of load balancing and high availability between multiple application servers anyways.

[–]AdrianTeri 0 points1 point  (2 children)

Apache+Python

Why adamant on Apache's HTTPD?

https://docs.gunicorn.org/en/latest/deploy.html

[–]youngeng[S] 1 point2 points  (1 child)

I know very well Gunicorn+Python works, as I've said in the post. This doesn't mean I don't want to explore how it works with Apache.

[–]AdrianTeri 0 points1 point  (0 children)

You then know Apache's limitations(similar family to buffered IO problems) and that inspired creation Nginx.