[Python-ideas] Tulip / PEP 3156 - subprocess events

Antoine Pitrou solipsis at pitrou.net
Sat Jan 19 01:19:55 CET 2013


On Fri, 18 Jan 2013 16:12:29 -0800
Guido van Rossum <guido at python.org> wrote:
> On Fri, Jan 18, 2013 at 3:59 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> > Guido van Rossum wrote:
> >
> >> Well, except that you can't just pass CallbackProtocol where a
> >> protocol factory is required by the PEP -- you'll have to pass a
> >> lambda or partial function without arguments that calls
> >> CallbackProtocol with some arguments taken from elsewhere.
> >
> >
> > Something smells wrong to me about APIs that require protocol
> > factories. I don't see what advantage there is in writing
> >
> >    create_connection(HTTPProtocol, "some.where.net", 80)
> >
> > as opposed to just writing something like
> >
> >    HTTPProtocol(TCPTransport("some.where.net", 80))

Except that you probably want the protocol to outlive the transport if
you want to deal with reconnections or connection failures, and
therefore:

    TCPClient(HTTPProtocol(), ("some.where.net", 80))

Regards

Antoine.





More information about the Python-ideas mailing list