how to do asynchronous http requests with epoll and python 3.1
Question: **UPDATE: after much laboring with Py3, including writing my own asynchronous
webserver (following a presentation given by Dave Beazley), i finally dumped
Python (and a huge stack of my code )-: in favor
of[CoffeeScript](http://coffeescript.org/) running on
[NodeJS](http://nodejs.org/). Check it out: [GitHub](https://github.com)
(where you'll find like 95% of all interesting code these days),
[npm](http://npmjs.org/) (package manager that couldn't be any user friendly;
good riddance, `easy_install`, you never lived up to your name), an insanely
huge repository of modules (with tons of new stuff being published virtually
24/7), a huge and vibrant community, out-of-the-box asynchronous HTTP and
filehandling..., all that (thanks to [V8](http://code.google.com/apis/v8/)) at
[one third the speed of
light](http://onlyjob.blogspot.com/2011/03/perl5-python-ruby-php-c-c-lua-
tcl.html) — what's not to like? read more propaganda: ["The future of
Scripting"](http://spreewebdesign.de/node/) (slide hosting courtesy
[SpreeWebdesign](http://spreewebdesign.de)).**

there is an interesting page <http://scotdoyle.com/python-epoll-howto.html>
about how to do asnchronous / non-blocking / AIO http serving in python 3.

there is the [tornado web server](http://www.tornadoweb.org/) which does
include a non-blocking http client. i have managed to port parts of the server
to python 3.1, but the implementation of the client requires
[pyCurl](http://pycurl.sourceforge.net/) and [seems to have
problems](http://groups.google.com/group/python-
tornado/browse_thread/thread/276059a076593266/c49e8f834497271e?lnk=gst&q=httpclient+trouble+with+epoll#c49e8f834497271e)
(with one participant stating how ‘Libcurl is such a pain in the neck’, and
looking at the incredibly ugly pyCurl page i doubt pyCurl will arrive in py3+
any time soon).

now that epoll is available in the standard library, it should be possible to
do asynchronous http requests out of the box with python. i really do not want
to use asyncore or whatnot; epoll has a reputation for being the ideal tool
for the task, and it is part of the python distribution, so using anything but
epoll for non-blocking http is highly counterintuitive (prove me wrong if you
feel like it).

oh, and i feel threading is horrible. no threading. i use
[stackless](http://stackless.com/).

_people further interested in the topic of asynchronous http should not miss
out on this[talk by peter portante at
PyCon2010](http://python.mirocommunity.org/video/1501/pycon-2010-demystifying-
non-bl); also of interest is [the
keynote](http://python.mirocommunity.org/video/1605/pycon-2010-keynote-
relentlessl), where speaker antonio rodriguez at one point emphasizes the
importance of having up-to-date web technology libraries right in the standard
library._

**edit** there may be many ways to achieve high throughputs with little
resource consumption. however, it is not only me who thinks that abandoning
threads (and other, partially outdated, methods); the people over at the
[google skipfish project](http://code.google.com/p/skipfish/wiki/SkipfishDoc)
seem to think similar: they say skipfish uses a

> Multiplexing single-thread, fully asynchronous network I/O and data
> processing model that eliminates memory management, scheduling, and IPC
> inefficiencies present in some multi-threaded clients.


Answer: In [this poll](http://www.mail-archive.com/python-bugs-
list@python.org/msg61273.html), months ago, Giampaolo Rodolá said

> I have a patch for adding epoll() support which is almost ready (asyncore
> supports poll(), not epoll()), it's just a matter of writing tests.

I'm not sure where to find that patch, but it seems a simple enough task that
it should be readily portable into `asyncore` (the standard python library
approach to async servers and clients -- sure, way behind Twisted or Tornado,
but that's what the stdlib has;-).

