Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Unfortunately this approach precludes GIL languages like Python. If you're able to use a language/runtime that is amenable to multithreading, then using a thread per connection works fine for most use cases (and it's probably easier than using whatever async/await interface your language has).


> probably easier than using whatever async/await interface your language has

Is it? I haven't used threads directly in a while, but I remember dealing with sinchronization issues. Problems that just don't exist in single threaded node with async await.

I find the async Promise or Task to be a more useful abstraction than the thread. Although, you need threads or a task dispatcher with a pool of threads if you need to run cpu intensive stuff.


If you’re just handling requests there isn’t much for shared state, so you don’t have to worry about synchronization.


> If you’re just handling requests there isn’t much for shared state

No, but if your single listener/server thread is managing epoll for all your file descriptors, you do have to have a way of synchronizing the worker threads with it, so they know when and when not to read from/write to their fd's. I assume Rachel is using some kind of semaphore or other threading synchronization mechanism for this.


Right, there is some shared state, but it’s very minimal.


True that the GIL prevents the specific expressed pattern you're talking about, but many have been able to do multiple threads and processes with Python itself and also things like gunicorn or uwsgi.


Yes, but I was responding to the article which was describing alternative patterns besides wsgi.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: