Fix missing cache hit bool element of return
parent
310d8f485e
commit
954dc6a8b0
|
@ -156,11 +156,11 @@ async def maybe_open_ctx(
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def get_and_use() -> AsyncIterable[T]:
|
def get_and_use() -> AsyncIterable[T]:
|
||||||
# key error must bubble here
|
# key error must bubble here
|
||||||
feed = cache.ctxs[key]
|
value = cache.ctxs[key]
|
||||||
log.info(f'Reusing cached feed for {key}')
|
log.info(f'Reusing cached feed for {key}')
|
||||||
try:
|
try:
|
||||||
cache.users += 1
|
cache.users += 1
|
||||||
yield True, feed
|
yield True, value
|
||||||
finally:
|
finally:
|
||||||
cache.users -= 1
|
cache.users -= 1
|
||||||
if cache.users == 0:
|
if cache.users == 0:
|
||||||
|
@ -168,16 +168,16 @@ async def maybe_open_ctx(
|
||||||
cache.no_more_users.set()
|
cache.no_more_users.set()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with get_and_use() as feed:
|
with get_and_use() as value:
|
||||||
yield True, feed
|
yield True, value
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# lock feed acquisition around task racing / ``trio``'s
|
# lock feed acquisition around task racing / ``trio``'s
|
||||||
# scheduler protocol
|
# scheduler protocol
|
||||||
await cache.lock.acquire()
|
await cache.lock.acquire()
|
||||||
try:
|
try:
|
||||||
with get_and_use() as feed:
|
with get_and_use() as value:
|
||||||
cache.lock.release()
|
cache.lock.release()
|
||||||
yield feed
|
yield True, value
|
||||||
return
|
return
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
Loading…
Reference in New Issue