New submission from Sebastian Rittau <[email protected]>:
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.
----------
components: asyncio
messages: 356962
nosy: asvetlov, srittau, yselivanov
priority: normal
severity: normal
status: open
title: async: Return context manager from open(_unix)_connection
versions: Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38846>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com