Skip to content

Commit

Permalink
workaround for PyPy hangs due non-awaited futures
Browse files Browse the repository at this point in the history
  • Loading branch information
mjurbanski-reef committed Jul 30, 2024
1 parent 269f575 commit 3d8b680
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions b2sdk/_internal/transfer/inbound/downloader/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from __future__ import annotations

import logging
import platform
import queue
import threading
from concurrent import futures
Expand Down Expand Up @@ -195,8 +196,15 @@ def _get_parts(
except futures.TimeoutError:
pass
else:
for stream in streams_futures.done:
stream.result()
try:
for stream in streams_futures.done:
stream.result()
except Exception:
if platform.python_implementation() == "PyPy":
# Await all threads to avoid PyPy hanging bug.
# https://github.com/pypy/pypy/issues/4994#issuecomment-2258962665
futures.wait(streams_futures.not_done)
raise
streams = streams_futures.not_done

futures.wait(streams)
Expand Down

0 comments on commit 3d8b680

Please sign in to comment.