Skip to content

[Python/Beam] Add MailboxProcessor tests and fix bugs#4360

Merged
dbrattli merged 2 commits intomainfrom
dbrattli/python-mailboxprocessor
Feb 25, 2026
Merged

[Python/Beam] Add MailboxProcessor tests and fix bugs#4360
dbrattli merged 2 commits intomainfrom
dbrattli/python-mailboxprocessor

Conversation

@dbrattli
Copy link
Collaborator

@dbrattli dbrattli commented Feb 25, 2026

Summary

  • Python: Convert mailbox_processor.py to PEP 695 type parameter syntax and add missing post_and_async_reply standalone function
  • Python: Create dedicated TestMailboxProcessor.fs with 13 comprehensive tests (moved out of TestAsync.fs)
  • Beam: Fix fable_async_builder:for/2 to handle seq/enumerable objects in async for-in loops (not just plain lists)
  • Beam: Fix fable_mailbox.erl cancellation — token was accepted but ignored; now stored in state and checked in process_events
  • Beam: Add 3 loop tests to LoopTests.fs isolating async for-in with negative step ranges

Note: No external changes for Python, everything as before. Only rewriting of fable-library. Fix for Beam, but beam has not been released yet so no need for a ChangeLog entry. Nothing changed.

Test plan

  • All 13 Python MailboxProcessor tests pass
  • All 2138 Beam tests pass (including new MailboxProcessor and loop tests)
  • Tests cover: basic post, postAndAsyncReply, falsy values, FIFO ordering, state accumulation, static/instance Start, buffering, error handling, cancellation, reply pairing, deep recursion, stateful replies

🤖 Generated with Claude Code

- Convert Python mailbox_processor.py to PEP 695 type parameter syntax
- Add missing standalone post_and_async_reply function for Python
- Create dedicated TestMailboxProcessor.fs for Python (13 tests) covering
  post, postAndAsyncReply, FIFO ordering, state accumulation, start
  methods, buffering, error handling, cancellation, reply pairing,
  deep recursion, and stateful replies
- Move mailbox test out of TestAsync.fs into its own file
- Expand Beam MailboxProcessorTests.fs from 3 to 13 tests (matching Python)
- Fix Beam async builder For to handle seq/enumerable (not just lists)
- Fix Beam MailboxProcessor to store and check cancellation token
- Add Beam loop tests for negative step ranges inside async

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Python Type Checking Results (Pyright)

Metric Value
Total errors 28
Files with errors 5
Excluded files 5
New errors ✅ No
Excluded files with errors (5 files)

These files have known type errors and are excluded from CI. Remove from pyrightconfig.ci.json as errors are fixed.

File Errors Status
temp/tests/Python/test_applicative.py 12 Excluded
temp/tests/Python/test_mailbox_processor.py 10 Excluded
temp/tests/Python/test_hash_set.py 3 Excluded
temp/tests/Python/test_nested_and_recursive_pattern.py 2 Excluded
temp/tests/Python/fable_modules/thoth_json_python/encode.py 1 Excluded

@dbrattli dbrattli changed the title [Python/Beam] Add comprehensive MailboxProcessor tests and fix bugs [Python/Beam] Add MailboxProcessor tests and fix bugs Feb 25, 2026
@dbrattli dbrattli merged commit 74e470c into main Feb 25, 2026
24 checks passed
@dbrattli dbrattli deleted the dbrattli/python-mailboxprocessor branch February 25, 2026 07:35
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