Skip to content

Commit

Permalink
Merge branch 'main' into refactor/ota_core
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang authored Nov 12, 2024
2 parents 3b8186a + e0b162e commit c813d06
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ota_proxy/cache_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ async def cache_streaming(
Raises:
CacheStreamingFailed if any exception happens during retrieving.
"""
_cache_write_gen = None
try:
_cache_write_gen = await tracker.start_provider(cache_meta)
_cache_writer_failed = False
Expand Down Expand Up @@ -370,8 +371,9 @@ async def cache_streaming(
finally:
# force terminate the generator in all condition at exit, this
# can ensure the generator being gced after cache_streaming exits.
with contextlib.suppress(StopAsyncIteration):
await _cache_write_gen.athrow(StopAsyncIteration)
if _cache_write_gen:
with contextlib.suppress(StopAsyncIteration):
await _cache_write_gen.athrow(StopAsyncIteration)

# remove the refs
fd, tracker = None, None # type: ignore
Expand Down

0 comments on commit c813d06

Please sign in to comment.