[Python-ideas] asyncore: included batteries don't fit
chrysn
chrysn at fsfe.org
Sat Sep 22 22:16:53 CEST 2012
On Sat, Sep 22, 2012 at 10:52:10PM +0400, Oleg Broytman wrote:
> If you mean that Twisted will be included in the standard library --
> then no, I'm sure it will not. Python comes with batteries included, but
> Twisted is not a battery, it's rather a power plant. I am sure it will
> always be developed and distributed separately.
> And developing asyncore to the level of Twisted would be a
> duplication of effort.
> PS. In my not so humble opinion what the standard library really lacks
> in this area is a way to combine a few asynchronous libraries with
> different mainloops. Think about wxPython+Twisted in one program. But I
> have no slightest idea how to approach the problem.
well, what about python including a battery and a battery plug, then?
asyncore could be the battery, and a interface between asynchronous
libraries the battery plug. users could start developing with batteries,
and when the project grows, just plug it into a power plant.
less analogy, more technical: the asyncore dispatcher to main loop
interface is pretty thin -- there is a (global or explicitly passed)
"map" (a dictionary), mapping file descriptors to objects that can be
readable or writable (or acceptable, not sure if that detail is really
needed that far down). a dispatcher registers to a map, and then the
main loop select()s for events on all files and dispatches them
accordingly.
it won't be as easy as just taking that interface, eg because it lacks
timeouts, but i think it can be the "way to combine a few asynchronous
libraries". (to avoid asyncore becoming a powerplant itself, it could
choose not to implement some features for simplicity. for example, if
asyncore chose to still not implement timeouts, registering timeouts to
a asyncore based main loop would just result in a NotImplementedError
telling the user to get a more powerful main loop.)
i don't want to claim i know how that could work in detail or even if it
could work at all, but if this is interesting for enough people that it
will be used, i'd like to find out.
> > then, again, subprocess and the onboard servers should work well
> > with *that* out of the box.
>
> If you want subprocess and Twisted to work together -- you know where
> to send patches.
no, actually -- for now, it'd be a patch to twisted (who'd reply with
"we already have a way of dealing with it"). if asyncore's interface
becomes the battery plug, it'd be a patch to subprocess.
thanks for sharing your ideas
chrysn
--
To use raw power is to make yourself infinitely vulnerable to greater powers.
-- Bene Gesserit axiom
-------------- 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/818d5445/attachment.pgp>
More information about the Python-ideas
mailing list