fix(types): T5 — narrow AsyncClient|None with inline if; rename loop variable t→task to avoid no-redef
This commit is contained in:
@@ -105,11 +105,11 @@ async def run_campaign_clusterer_loop(
|
||||
t.cancel()
|
||||
if heartbeat_task is not None:
|
||||
heartbeat_task.cancel()
|
||||
for t in (*wake_tasks, heartbeat_task):
|
||||
if t is None:
|
||||
for task in (*wake_tasks, heartbeat_task):
|
||||
if task is None:
|
||||
continue
|
||||
with contextlib.suppress(asyncio.CancelledError, Exception):
|
||||
await t
|
||||
await task
|
||||
if bus is not None:
|
||||
with contextlib.suppress(Exception):
|
||||
await bus.close()
|
||||
|
||||
@@ -115,11 +115,11 @@ async def run_clusterer_loop(
|
||||
t.cancel()
|
||||
if heartbeat_task is not None:
|
||||
heartbeat_task.cancel()
|
||||
for t in (*wake_tasks, heartbeat_task):
|
||||
if t is None:
|
||||
for task in (*wake_tasks, heartbeat_task):
|
||||
if task is None:
|
||||
continue
|
||||
with contextlib.suppress(asyncio.CancelledError, Exception):
|
||||
await t
|
||||
await task
|
||||
if bus is not None:
|
||||
with contextlib.suppress(Exception):
|
||||
await bus.close()
|
||||
|
||||
@@ -120,11 +120,11 @@ async def run_reuse_loop(
|
||||
t.cancel()
|
||||
if heartbeat_task is not None:
|
||||
heartbeat_task.cancel()
|
||||
for t in (*wake_tasks, heartbeat_task):
|
||||
if t is None:
|
||||
for task in (*wake_tasks, heartbeat_task):
|
||||
if task is None:
|
||||
continue
|
||||
with contextlib.suppress(asyncio.CancelledError, Exception):
|
||||
await t
|
||||
await task
|
||||
if bus is not None:
|
||||
with contextlib.suppress(Exception):
|
||||
await bus.close()
|
||||
|
||||
@@ -200,11 +200,11 @@ async def run_intel_loop(
|
||||
t.cancel()
|
||||
if heartbeat_task is not None:
|
||||
heartbeat_task.cancel()
|
||||
for t in (*wake_tasks, heartbeat_task):
|
||||
if t is None:
|
||||
for task in (*wake_tasks, heartbeat_task):
|
||||
if task is None:
|
||||
continue
|
||||
with contextlib.suppress(asyncio.CancelledError, Exception):
|
||||
await t
|
||||
await task
|
||||
if bus is not None:
|
||||
with contextlib.suppress(Exception):
|
||||
await bus.close()
|
||||
|
||||
@@ -405,11 +405,11 @@ async def run_watch_loop(repo: BaseRepository, poll_interval_secs: int = 10) ->
|
||||
t.cancel()
|
||||
if heartbeat_task is not None:
|
||||
heartbeat_task.cancel()
|
||||
for t in (*wake_tasks, heartbeat_task):
|
||||
if t is None:
|
||||
for task in (*wake_tasks, heartbeat_task):
|
||||
if task is None:
|
||||
continue
|
||||
with contextlib.suppress(asyncio.CancelledError, Exception):
|
||||
await t
|
||||
await task
|
||||
if bus is not None:
|
||||
with contextlib.suppress(Exception):
|
||||
await bus.close()
|
||||
|
||||
@@ -148,7 +148,7 @@ async def deliver(
|
||||
url = sub["url"]
|
||||
|
||||
owns_client = client is None
|
||||
if owns_client:
|
||||
if client is None:
|
||||
client = httpx.AsyncClient(timeout=timeout_s)
|
||||
|
||||
last_status: Optional[int] = None
|
||||
|
||||
@@ -85,7 +85,7 @@ async def webhook_worker(
|
||||
|
||||
shutdown = asyncio.Event()
|
||||
owns_http = http_client is None
|
||||
if owns_http:
|
||||
if http_client is None:
|
||||
http_client = httpx.AsyncClient(timeout=10.0)
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user