Skip to content

BUG: Release the usage sharing element without waiting for its sending thread - #275

Merged
jwrosewell merged 1 commit into
rcfrom
fix/usage-sharing-release
Nov 23, 2026
Merged

jwrosewell merged 1 commit into
rcfrom
fix/usage-sharing-release

Conversation

@Mykhailo51D

Copy link
Copy Markdown
Collaborator

What changed

ShareUsage.__del__ in pipeline/fiftyone_pipeline_engines_fiftyone/src/fiftyone_pipeline_engines_fiftyone/share_usage.py now calls thread_pool.shutdown(wait=False) every time. Before, it waited for the sending thread when the element had not been closed.

Why

The garbage collector calls __del__ on whichever thread it happens to run on. In the release run for #240, the Python 3.10 build entries on Ubuntu and Windows stopped in tests/test_usage.py and ran until the two-hour job limit. A local run on Python 3.10.11 hung in the same way, and the stack dump showed why. A new sending thread was starting and held the lock in threading that tracks running threads. The collector ran on that thread and released an earlier element that had never been closed. Its __del__ then joined that element's sending thread, and the join needs that same lock, so it never returned. The test thread waited for the new thread to start, and the run stopped.

Closing still sends what is queued, within its five-second bound. A message already going out when an element is released still finishes on the sending thread, and the interpreter waits for that thread at exit.

Tests

  • New pipeline/fiftyone_pipeline_engines_fiftyone/tests/test_share_usage_release.py, with one test. It holds a send, releases the element on a thread of its own, and checks that releasing returns while the send is still held and that the message is sent once the send is let go. Before the change it failed after 30 seconds ("Releasing the element waited for the message being sent."). After the change it passes.
  • tests/test_usage.py on Python 3.10.11 (Windows): before the change, 1 of 6 runs hung after 35 tests. After the change, 12 of 12 runs passed, with 40 tests in each.
  • The whole fiftyone_pipeline_engines_fiftyone test suite: 156 passed on Python 3.10.11 and 156 passed on Python 3.12.

…g thread

When the garbage collector releases a usage sharing element that was never
closed, the element now stops its sending thread without waiting for it. The
collector can run on any thread, including a new thread that is starting and
holds the lock a thread needs to end. Waiting there never returned, and the
usage sharing tests stopped until the job's time limit.

A message already going out still finishes on the sending thread, which the
interpreter waits for at exit.

test_share_usage_release.py checks that releasing returns while a send is
held, and that the held message is sent once it is let go.
@jwrosewell
jwrosewell marked this pull request as ready for review November 23, 2026 22:55
@jwrosewell
jwrosewell merged commit 64b74cf into rc Nov 23, 2026
7 checks passed
@jwrosewell
jwrosewell deleted the fix/usage-sharing-release branch November 23, 2026 22:55
@jwrosewell jwrosewell mentioned this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants