Skip to content

Fix SimpleQueue get and argument handling - #9641

Closed
youknowdot wants to merge 4 commits into
RustPython:mainfrom
youknowdot:fix/simplequeue-nonblocking-permit-20261103
Closed

youknowdot wants to merge 4 commits into
RustPython:mainfrom
youknowdot:fix/simplequeue-nonblocking-permit-20261103

Conversation

@youknowdot

@youknowdot youknowdot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Route SimpleQueue.get(block=False) through the existing nonblocking removal path. Previously a threaded nonblocking get removed an item without consuming its semaphore permit, so later consumers could observe stale permits.
  • Publish each enqueued item and its permit before releasing the buffer lock, preventing another thread from observing an item before a nonblocking getter can claim its permit. Construct an empty-queue exception after releasing the buffer lock.
  • Apply Python truth testing to the block argument for put and get, after argument binding; preserve explicit None as false.
  • Ignore the timeout for nonblocking calls. For blocking calls, convert __index__ before __float__, validate signed nanosecond bounds and round up as CPython does, reject NaN/negative values appropriately, and use checked deadline addition. Infinite or very large timeouts no longer reach a panicking Duration::from_secs_f64 path.

Scope

Generic argument-binding diagnostics, lower-level numeric-slot diagnostics, existing item ownership, waiting/polling behavior and direct-handoff/fairness differences are not addressed. put still acquires the same two mutexes but now holds them together briefly, so contention effects are unbenchmarked. If a platform's Instant cannot represent a valid deadline, this returns OverflowError; CPython instead saturates its internal deadline.

Validation

  • Traced semaphore and buffer states across mixed get(False), get(), get_nowait(), put and qsize calls, including lock ordering and stop-the-world interactions. Existing Lib/test/test_queue.py exercises mixed and concurrent nonblocking calls.
  • Compared CPython 3.15.0 queue and time conversion source and reproduced truth testing, ignored nonblocking timeouts, __index__ precedence, propagated callback errors, nanosecond rounding, NaN and overflow cases.
  • Independent source review for all four commits and normal commit hooks passed.
  • RustPython was not built or executed locally; stale-permit and panic paths are inferred from source, not locally reproduced. No tests were added or changed.

Assisted-by: OpenAI Codex:model version not exposed
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

Assisted-by: OpenAI Codex:model version not exposed
@youknowdot youknowdot changed the title Consume permits for nonblocking SimpleQueue get Fix SimpleQueue nonblocking get and timeout handling Nov 3, 2026
Assisted-by: OpenAI Codex:model version not exposed
@youknowdot youknowdot changed the title Fix SimpleQueue nonblocking get and timeout handling Fix SimpleQueue get and argument handling Nov 3, 2026
Assisted-by: OpenAI Codex:model version not exposed
youknowdot added a commit to youknowdot/RustPython that referenced this pull request Nov 6, 2026
Incorporate RustPython#9641 intact, preserving its original commits and attribution.

Assisted-by: OpenAI Codex:model version not exposed
@youknowdot

Copy link
Copy Markdown
Contributor Author

Consolidated into #9652 at 8e59835. All four original commits are preserved as ancestors, including the nonblocking permit and atomic-publication fixes. SimpleQueue now shares pytime conversion while retaining its ceiling rounding and caller-specific timeout policy. The combined test_queue suite passed; full aggregate checks and exact-head CI remain pending. Closing this duplicate without deleting its branch.

@youknowdot youknowdot closed this Nov 6, 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.

1 participant