Closed ghost closed 8 years ago
@@ master #258 diff @@
==========================================
Files 4 4
Lines 476 478 +2
Methods 0 0
Messages 0 0
Branches 75 75
==========================================
+ Hits 430 432 +2
Misses 31 31
Partials 15 15
Powered by Codecov. Last update ce33c51...3400277
safer way to close. LGTM.
As a side note, the finally
block also hooks into the __del__
behavior of generators
def my_gen():
try:
for j in range(5):
print('in loop', j)
yield j
finally:
print('finally')
In [3]: list(my_gen())
in loop 0
in loop 1
in loop 2
in loop 3
in loop 4
finally
Out[3]: [0, 1, 2, 3, 4]
In [4]: g = my_gen()
In [5]: next(g)
in loop 0
Out[5]: 0
In [6]: next(g)
in loop 1
Out[6]: 1
In [7]: del g
finally
If you dig into the __die() method in pymongo driver, it does something similar. It doesn't hurt being safe
Closes #257
Attn. @tacaswell @hhslepicka
See issue #257