Skip to content

Commit 0b8912a

Browse files
committed
Shield internal block procedures from cancellation
due to connection close() (that the Monitor triggers) because of any connection issues on the underlying websocket.
1 parent c526d17 commit 0b8912a

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

juju/jasyncio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
gather, sleep, wait_for, create_subprocess_exec, subprocess, \
2222
wait, FIRST_COMPLETED, Lock, as_completed, new_event_loop, \
2323
get_event_loop_policy, CancelledError, get_running_loop, \
24-
create_task, ALL_COMPLETED, all_tasks, current_task # noqa
24+
create_task, ALL_COMPLETED, all_tasks, current_task, shield # noqa
2525

2626

2727
def create_task_with_handler(coro, task_name, logger=ROOT_LOGGER):

juju/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ async def block_until(*conditions, timeout=None, wait_period=0.5):
128128
async def _block():
129129
while not all(c() for c in conditions):
130130
await jasyncio.sleep(wait_period)
131-
await jasyncio.wait_for(_block(), timeout)
131+
await jasyncio.shield(jasyncio.wait_for(_block(), timeout))
132132

133133

134134
async def block_until_with_coroutine(condition_coroutine, timeout=None, wait_period=0.5):
@@ -139,7 +139,7 @@ async def block_until_with_coroutine(condition_coroutine, timeout=None, wait_per
139139
async def _block():
140140
while not await condition_coroutine():
141141
await jasyncio.sleep(wait_period)
142-
await jasyncio.wait_for(_block(), timeout=timeout)
142+
await jasyncio.shield(jasyncio.wait_for(_block(), timeout=timeout))
143143

144144

145145
async def wait_for_bundle(model, bundle, **kwargs):

0 commit comments

Comments
 (0)