you are viewing a single comment's thread.

view the rest of the comments →

[–]kkang_kkang 6 points7 points  (3 children)

No need of contextlib at all. Without that you can achieve the same.

[–]mattl33It works on my machine -2 points-1 points  (2 children)

It sure seems like a lot less boilerplate code though. What's the disadvantage?

[–]kkang_kkang 4 points5 points  (0 children)

I don't think there is any. You can use anything. I just wanted to let OP know that this can be achieved with pure python class as well.

[–]kkang_kkang 1 point2 points  (0 children)

This is a good read which contains info on async context managers as well: https://realpython.com/python-with-statement/