Message372875
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? |
|
Date |
User |
Action |
Args |
2020-07-02 19:37:33 | uburuntu | set | recipients:
+ uburuntu, serhiy.storchaka, yselivanov |
2020-07-02 19:37:33 | uburuntu | set | messageid: <1593718653.77.0.225340062457.issue41197@roundup.psfhosted.org> |
2020-07-02 19:37:33 | uburuntu | link | issue41197 messages |
2020-07-02 19:37:33 | uburuntu | create | |
|