Ramzan Bekbulatov <[email protected]> added the comment:
In this case:
```python3
class A:
async def close(self):
pass
with closing(A()):
pass
```
Python will raise `RuntimeWarning: coroutine 'A.close' was never awaited`.
In another case:
```python3
class B:
def close(self):
pass
async with closing(B()):
pass
```
Python will raise `TypeError: object NoneType can't be used in 'await'
expression` (because it will try to await result of close method).
-----
I was surprised that `contextlib` has no async analogue of this `closing`
class, because async scripts often use any kind of closings. Do you think it's
better to extract to `asyncclosing` class?
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41197>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com