[Web-SIG] ngx.poll extension (was Re: Are you going to convert Pylons code into Python 3000?)

Graham Dumpleton graham.dumpleton at gmail.com
Fri Mar 7 00:25:08 CET 2008

On 07/03/2008, Manlio Perillo <manlio_perillo at libero.it> wrote:
>  Moreover with an asynchronous gateway it is possible to implement a
>  "middleware" that can execute an application inside a thread.
>  This is possible by creating a pipe, starting a new thread, having the
>  main thread polling the pipe, and having the thread write some data in
>  the pipe to "wake" the main thread when finish its job.
>  I'm going to write a sample implementation when I find some time.
>  Yes, we need to use a thread, but this can be done in pure Python code
>  only (altought I'm not sure if this can have side effects on Nginx).

So you do understand this technique of using a socketpair() pipe as a
way of communicating between code which is thread safe and other code
which is potentially non thread safe. This makes moot your prior point
that they (threads) are not supported by the server and thus you want
to avoid using them.

In other words, as I have pointed out previously, in practice it would
be possible to implement a thread pool mechanism on top of nginx such
that you could avoid this whole problem of the asynchronous model at
the WSGI level.

I still don't understand why you are so resistant to going this path
given that for Python web applications, the event driven model doesn't
necessarily provide any benefits when one looks at the bigger picture
and perhaps just makes it harder to implement application code.

If you want to pursue an even driven model because you find it an
interesting area to work in then fine, but you shouldn't expect
everyone else to try and accommodate that way of thinking when people
are happy with the alternative.


More information about the Web-SIG mailing list