Hello.

I've read the PEP and some things raise questions in my consciousness. Here
they are.

1. Series of sock_ methods can be organized into a wrapper around sock
object. This wrappers can then be saved and used later in async-aware code.
This way code like:

    sock = socket(...)
    # later, e.g. in connect()
    yield from tulip.get_event_loop().sock_connect(sock, ...)
    # later, e.g. in read()
    data = yield from tulip.get_event_loop().sock_recv(sock, ...)

will look like:

    sock = socket(...)
    async_sock = tulip.get_event_loop().wrap_socket(sock)
    # later, e.g. in connect()
    yield from async_sock.connect(...)
    # later, e.g. in read()
    data = yield from async_sock.recv(...)

Interface looks cleaner while plain calls (if they ever needed) will be
only 5 chars longer.

2. Not as great, but still possible to wrap fd in similar way to make
interface simpler. Instead of:

    add_reader(fd, callback, *args)
    remove_reader(fd)

We can do:

    wrap_fd(fd).reader = functools.partial(callback, *args)
    wrap_fd(fd).reader = None  # or
    del wrap_fd(fd).reader

3. Why not use properties (or fields) instead of methods for cancelled,
running and done in Future class? I think, it'll be easier to use since I
expect such attributes to be accessed as properties. I see it as some
javaism since in Java Future have getters for this fields but they are
prefixed with 'is'.

4. Why separate exception() from result() for Future class? It does the
same as result() but with different interface (return instead of raise).
Doesn't this violate the rule "There should be one obvious way to do it"?

5. I think, protocol and transport methods' names are not easy or
understanding enough:
- write_eof() does not write anything but closes smth, should be
close_writing or smth alike;
- the same way eof_received() should become smth like receive_closed;
- pause() and resume() work with reading only, so they should be suffixed
(prefixed) with read(ing), like pause_reading(), resume_reading().


Kind regards, Yuriy.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to