Python: Add drain method to get all events within the dora queue#1177
Python: Add drain method to get all events within the dora queue#1177haixuanTao merged 11 commits intomainfrom
Conversation
9acd776 to
2b4239d
Compare
| if self.scheduler.is_empty() { | ||
| if let Some(event) = self.receiver.next().await { | ||
| self.scheduler.add_event(event); | ||
| } else { | ||
| break; | ||
| } | ||
| } else { | ||
| match select(Delay::new(Duration::from_micros(300)), self.receiver.next()).await { | ||
| Either::Left((_elapsed, _)) => break, | ||
| Either::Right((Some(event), _)) => self.scheduler.add_event(event), | ||
| Either::Right((None, _)) => break, | ||
| }; | ||
| } |
There was a problem hiding this comment.
Could you clarify what you're trying to do here? It looks like this code will just block until the event channel is closed?
|
I'm not sure if this is the best approach to empty the queues. How about we instead add a Such a function would allow node authors to empty the queue themselves by just calling fn drain(&mut self) -> Vec<Event> {
let mut events = Vec::new();
while let Some(event) = self.try_recv() {
events.push(event);
}
events
}This pattern is common in the Rust ecosystem.
I'm not sure if I understand this part. How is a different drain order faster? |
a890ef2 to
54ef17b
Compare
|
I just opened #1185 to provied a simpler |
54ef17b to
beb9931
Compare
b952e46 to
4c527aa
Compare
4c527aa to
24d60c2
Compare
In order to reduce having too many filled queues., node.drain() enable to get all event from all input as a vec/list.
In order to make this fast and manageable the order of draining is going to be first ordered by topic and then by time of arrival