Emit an event right before the event dispatch loop starts#58
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “loop started” hook to Basana’s dispatchers so consumers can run async initialization logic exactly once right before the dispatcher begins its dispatch loop (useful for pre-loop setup that must happen after run() begins, but before any events are processed).
Changes:
- Introduces
subscribe_event_loop_started()onEventDispatcherand notifies registered handlers at the start of the dispatch loop. - Wires the notification into both
RealtimeDispatcherandBacktestingDispatcherdispatch loops. - Adds/updates tests and documentation (CHANGELOG + repo Copilot instructions) to cover and describe the new behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
basana/core/dispatcher/base.py |
Adds loop-started handler type, subscription API, and notification helper. |
basana/core/dispatcher/realtime.py |
Calls the loop-start notification before entering the realtime dispatch loop. |
basana/core/dispatcher/backtesting.py |
Sets initial backtesting “now” (from next event) and calls the loop-start notification before processing. |
basana/core/dispatcher/__init__.py |
Exports LoopStartedHandler in the dispatcher package API surface. |
tests/test_realtime_dispatcher.py |
Adds coverage ensuring realtime loop-start handlers are invoked once. |
tests/test_backtesting_dispatcher.py |
Adds coverage for backtesting loop-start invocation and duplicate subscription behavior. |
CHANGELOG.md |
Documents the new subscribe_event_loop_started feature. |
.github/copilot-instructions.md |
Updates repository workflow/testing guidance and adds testing conventions. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Will take it into account for your his performance review. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
No description provided.