Skip to content

Deduplicate awaitable check in request handlers#1507

Open
erikgaas wants to merge 2 commits intoipython:mainfrom
erikgaas:deduplicate-awaitable-check
Open

Deduplicate awaitable check in request handlers#1507
erikgaas wants to merge 2 commits intoipython:mainfrom
erikgaas:deduplicate-awaitable-check

Conversation

@erikgaas
Copy link

@erikgaas erikgaas commented Mar 6, 2026

Summary

Every request handler in kernelbase.py had the same 7-line pattern checking if the do_* method returned an awaitable and warning if not. This PR extracts that into a single _await_result() helper.

Changes

  • Add _await_result(result, func_name) method to Kernel class
  • Replace 7 identical check-and-warn blocks with one-line calls

erikgaas and others added 2 commits March 6, 2026 11:45
Extract repeated 7-line pattern into _await_result() helper method.
Each request handler (do_execute, do_complete, do_inspect, do_history,
do_shutdown, do_is_complete, do_debug_request) had an identical block
checking if the result was awaitable and warning if not.

Reduces ~42 lines of duplicated code to 7 one-line call sites.
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