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

Guido van Rossum guido at python.org
Sat Jan 19 01:12:29 CET 2013


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))
>
> You're going to have to use the latter style anyway to set up
> anything other than the very simplist configurations, e.g.
> your earlier 4-layer protocol stack example.
>
> So create_connection() can't be anything more than a convenience
> function, and unless I'm missing something, it hardly seems to
> add enough convenience to be worth the bother.

Glyph should really answer this one. Personally I don't feel strongly
either way for this case. There may be an advantage to not calling the
protocol factory if the connection can't be made (in which case the
Future returned by create_connection() has the exception).

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list