Skip to content

Commit fe358b5

Browse files
committed
fix: shield shared in-flight RQ add markers from caller cancellation
1 parent 9cea9a4 commit fe358b5

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/apify/storage_clients/_apify/_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import asyncio
34
import re
45
from base64 import b64encode
56
from hashlib import sha256
@@ -11,7 +12,6 @@
1112
from apify import Request
1213

1314
if TYPE_CHECKING:
14-
import asyncio
1515
from collections.abc import Iterable
1616

1717
from apify_client._models import HeadRequest, LockedHeadRequest
@@ -95,7 +95,9 @@ async def resolve_awaited_in_flight(
9595
so the caller retries them rather than receiving false success.
9696
"""
9797
for request, future in awaited_in_flight:
98-
if await future:
98+
# Shield the shared in-flight marker: cancelling this awaiting caller must not cancel the future, which
99+
# is owned by the original producer and may have other callers waiting on it.
100+
if await asyncio.shield(future):
99101
api_response.processed_requests.append(
100102
ProcessedRequest(
101103
id=unique_key_to_request_id(request.unique_key),

0 commit comments

Comments
 (0)