fix: replace blocking requests.post with aiohttp in GovernanceEthereum#1721
Merged
openminddev merged 3 commits intoOpenMind:mainfrom Jan 20, 2026
Merged
Conversation
The load_rules_from_blockchain() method was using blocking requests.post() which blocked the async event loop, preventing other coroutines from running. Changes: - Replace requests.post with aiohttp async HTTP client - Make load_rules_from_blockchain() async method - Move blockchain loading from __init__ to first _poll() call - Add specific exception handling for ClientError and TimeoutError - Add POLL_INTERVAL type hint for float compatibility - Update tests with async mocks and 100% coverage - Add edge case tests for short hex, control chars, missing result key
Removed redundant comments and improved type annotations in the GovernanceEthereum class. Updated tests to add descriptive docstrings, fixed POLL_INTERVAL type assertion, and enhanced test clarity for edge cases and error handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix critical event loop blocking bug in
GovernanceEthereuminput plugin. Theload_rules_from_blockchain()method was using synchronousrequests.post()which blocked the entire async event loop for up to 10 seconds during blockchain RPC calls.Problem
The original implementation had two critical issues:
requests.post()(synchronous) instead ofaiohttp(async)__init__: Called the blocking method during initializationImpact: During initialization and every poll, the entire event loop would freeze for up to 10+ seconds, preventing all other coroutines (camera, ASR, GPS, etc.) from running.
Solution
requests.postwithaiohttp.ClientSessionfor non-blocking HTTPload_rules_from_blockchain()an async method__init__to first_poll()callaiohttp.ClientErrorandasyncio.TimeoutErrorChanges
src/inputs/plugins/ethereum_governance.pytests/inputs/base/test_governance_ethereum.pyNon-Blocking Verification
Added tests that run concurrent tasks during HTTP calls to verify the event loop is not blocked:
Test Coverage
Related PR
This PR supersedes #1361 which only added tests without the blocking fix. This PR includes:
Test Plan
uv run ruff check- Passeduv run black --check- Passeduv run isort --check-only- Passeduv run pyright- 0 errorsuv run pytest tests/inputs/base/test_governance_ethereum.py -v- 24 passeduv run pre-commit run --files- All passed