Message372871
# Async magic methods in contextlib.closing
I think `__aenter__` and `__aexit__` methods should be added to `contextlib.closing`, so that we can use `contextlib.closing` in async code too.
For example:
```python3
class SomeAPI:
...
async def request(self):
pass
async def close(self):
await self.session.close()
async with closing(SomeAPI()) as api:
response = await api.request()
print(response)
```
Also these methods can be moved to another class (like `asyncclosing` along the lines of `asynccontextmanager`). |
|
Date |
User |
Action |
Args |
2020-07-02 18:22:53 | uburuntu | set | recipients:
+ uburuntu |
2020-07-02 18:22:53 | uburuntu | set | messageid: <1593714173.91.0.0149218020987.issue41197@roundup.psfhosted.org> |
2020-07-02 18:22:53 | uburuntu | link | issue41197 messages |
2020-07-02 18:22:53 | uburuntu | create | |
|