Replies: 1 comment 1 reply
-
When events are pushed they get pushed into a queue, this is, the event source queue. That queue will be processed by the dispatcher and events will be processed in order using the event's datetime (https://basana.readthedocs.io/en/latest/basana.html#basana.Event.when). Going back to your example, the event generated by callback1 will have a greater datetime than the event currently being processed, so it will be processed after callback2 gets called.
Let me know if this helps. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I'm new to basana (masterpiece code really!), and very interested in its event queue design.
I had some trading scripts written by myself, which also have a Producer (Broker) to receive streaming data from broker then call all subscribed callbacks (by Strategies) directly. So the control flow (callback chain) is very simple for me.
Then I found basana, it uses a very cool event queue design, decouple every component by just using event! But I have a small question about its callbacks execution order (maybe I need to read its source code).
See, event dispatcher pop event A, which has two callbacks subscribed callback1 and callback2. The dispatcher would execute callback1 first, what if it push another event B (subscribed by callback3). My question is the execution orders of callback2 and callback3. Will the callback3 be executed after callback2?
If using simple callback chain, callback3 will be executed before callback2, like:
Maybe I missed something, thanks!
Beta Was this translation helpful? Give feedback.
All reactions