This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author srittau
Recipients asvetlov, srittau, yselivanov
Date 2019-11-19.11:54:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1574164468.11.0.934598090921.issue38846@roundup.psfhosted.org>
In-reply-to
Content
As a convenience it would be useful if async.open_connection() and open_unix_connection() would return a context manager that closes the writer on exit:

    with await open_unix_connection(...) as (reader, writer):
        ...

This could be achieved by using a custom sub-class of tuple:

    class _ConnectionContext(tuple):
        def __enter__(self):
            return self
        def __exit__(self, *args):
            self[1].close()

I can submit a PR if wanted.
History
Date User Action Args
2019-11-19 11:54:28srittausetrecipients: + srittau, asvetlov, yselivanov
2019-11-19 11:54:28srittausetmessageid: <1574164468.11.0.934598090921.issue38846@roundup.psfhosted.org>
2019-11-19 11:54:28srittaulinkissue38846 messages
2019-11-19 11:54:27srittaucreate