NSLS-II / metadatastore

DEPRECATED: Incorporated into https://github.com/NSLS-II/databroker
Other
2 stars 11 forks source link

ENH:Keep event cursor alive until completely consumed #258

Closed ghost closed 7 years ago

ghost commented 7 years ago

Attn. @tacaswell @hhslepicka

See issue #257

codecov-io commented 7 years ago

Current coverage is 90.37% (diff: 100%)

Merging #258 into master will increase coverage by 0.04%

@@             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

licode commented 7 years ago

safer way to close. LGTM.

tacaswell commented 7 years ago

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
ghost commented 7 years ago

If you dig into the __die() method in pymongo driver, it does something similar. It doesn't hurt being safe

ghost commented 7 years ago

Closes #257