Skip to content

Add erlang.schedule_inline() for inline continuations#28

Merged
benoitc merged 5 commits intomainfrom
feature/schedule-inline
Mar 14, 2026
Merged

Add erlang.schedule_inline() for inline continuations#28
benoitc merged 5 commits intomainfrom
feature/schedule-inline

Conversation

@benoitc
Copy link
Owner

@benoitc benoitc commented Mar 14, 2026

Summary

  • Add erlang.schedule_inline() which bypasses Erlang messaging using enif_schedule_nif() to chain Python calls directly
  • Works with all py:call() variants
  • Includes 8 new test cases

Usage

def process_batch(data, offset=0):
    # process chunk...
    if erlang.consume_time_slice(25):
        return erlang.schedule_inline('__main__', 'process_batch', args=[data, offset+100])
    return results

benoitc added 5 commits March 14, 2026 10:36
Bypasses Erlang messaging by using enif_schedule_nif() to chain Python
calls directly. Works with all py:call() variants.
- Add bench_schedule_inline comparing schedule_inline vs schedule_py
- Use explicit context in test_schedule_inline_to_schedule_py for CI
Captures frame globals/locals when erlang.schedule_inline() is called
and uses them for function lookup in the continuation. This ensures
correct namespace resolution with subinterpreters.

Adds test_schedule_inline_captures_globals to verify behavior.
Use py:context() for all tests that pair py:exec with py:eval
to ensure consistent namespace across different platforms.
- Document erlang.schedule_inline() in asyncio.md
- Add comparison table (schedule_inline vs schedule_py)
- Update "When to Use Each Pattern" table
- Add v2.3.0 changelog entry
@benoitc benoitc force-pushed the feature/schedule-inline branch from c36c5b8 to de5f729 Compare March 14, 2026 10:38
@benoitc benoitc merged commit f5bd67e into main Mar 14, 2026
11 checks passed
@benoitc benoitc deleted the feature/schedule-inline branch March 14, 2026 10:48
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