[Python-ideas] asyncore: included batteries don't fit

chrysn chrysn at fsfe.org
Sat Sep 22 18:31:06 CEST 2012


hello python-ideas,

i'd like to start discussion about the state of asyncore/asynchat's
adaption in the python standard library, with the intention of finding a
roadmap for how to improve things, and of kicking off and coordinating
implementations.

here's the problem (as previously described in [issue15978] and
redirected here, with some additions):

the asyncore module would be much more useful if it were well integrated
in the standard library. in particular, it should be supported by:

* subprocess

* BaseHTTPServer / http.server (and thus, socketserver)

* urllib2 / urllib, http.client

* probably many other network libraries except smtpd, which already uses
  asyncore

* third party libraries (if stdlib leads the way, the ecosystem will
  follow; eg pyserial)

without widespread asyncore support, it is not possible to easily
integrate different servers and services with each other; with asyncore
support, it's just a matter of creating the objects and entering the
main loop. (eg, a http server for controlling a serial device, with a
telnet-like debugging interface).

some examples of the changes required:

* the socketserver documents that it would like to have such a
  framework ("Future work: [...] Standard framework for select-based
  multiplexing"). due to the nature of socketserver based
  implementations (blocking reads), we can't just "add glue so it
  works", but there could be extensions so that implementations can be
  ported to asynchronous socketservers. i've done if for a particular
  case (ported SimpleHTTPServer, but it's a mess of monkey-patching and
  intermediate StringIOs).

* for subprocess, there's a bunch of recipies at [1].

* pyserial (not standard library, but might as well become) can be
  ported quite easily [2].


this touches several modules whose implementations can be handled
independently from each other; i'd implement some of them myself.
terry.reedy redirected me from the issue tracker to this list, hoping
for controversy and alternatives. if you'd like to discuss, throw in
questions, and we'll find a solution. if you'd think talk is cheap, i
can try to work out first sketches.


python already has batteries for nonblocking operation included, and i
say it's doing it right -- let's just make sure the batteries fit in the
other gadgets!


yours truly
chrysn


[1] http://code.activestate.com/recipes/576957-asynchronous-subprocess-using-asyncore/
[2] http://sourceforge.net/tracker/?func=detail&aid=3559321&group_id=46487&atid=446305
[issue15978] http://bugs.python.org/issue15978


-- 
Es ist nicht deine Schuld, dass die Welt ist, wie sie ist -- es wär' nur
deine Schuld, wenn sie so bleibt.
(You are not to blame for the state of the world, but you would be if
that state persisted.)
  -- Die Ärzte
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120922/dda79107/attachment.pgp>


More information about the Python-ideas mailing list