You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With this change, if the queue contains a batch of events, react only to the latest one — to follow the "eventual consistency" principle of Kubernetes.
The batch is time-framed to 0.1s, so that it is fast enough for all normal cases when only one event arrives, but slow enough for the initial object listing when multiple events arrive.
Still, some minimal time-frame is needed, as the streaming and parsing of the events inside of the kubernetes library is not immediate.
Commented by samurang87 at 2019-04-26 12:58:44+00:00
So basically if the fetching manages to get any events, you restart it to make sure there is only one event fetched? 🤔
threading.Queue().qsize() on Mac OS (it is not supported), so I used to avoid qsize() and just to not think about it. It is promised to work normally in asyncio.Queue though.
If the queue is empty (qsize == 0), we should wait for 5.0 seconds until something appears. So, while queue.qsize() > 0: is not a suitable criterion here, unless first_time is introduced. But it makes it same as not nice as double tries. In that case, it would look like this:
event=Nonefirst_time=Truetry:
whilefirst_timeorqueue.qsize() >0:
first_time=Falseevent=awaitasyncio.wait_for(queue.get(), timeout=5.0)
exceptasyncio.TimeoutError:
ifeventisNone:
break# when (event is not None) or (no timeout on the last event), continue.
The text was updated successfully, but these errors were encountered:
With this change, if the queue contains a batch of events, react only to the latest one — to follow the "eventual consistency" principle of Kubernetes.
The batch is time-framed to 0.1s, so that it is fast enough for all normal cases when only one event arrives, but slow enough for the initial object listing when multiple events arrive.
Still, some minimal time-frame is needed, as the streaming and parsing of the events inside of the kubernetes library is not immediate.
So basically if the fetching manages to get any events, you restart it to make sure there is only one event fetched? 🤔
samurang87 Yes. And getting all the events till nothing is left. All events except the last one are therefore ignored — as intended.
Why will the event we are interested in be fetched rapidly ? And why will the number of event decrease ?
parking52 samurang87 I didn't get your last comments. What number of events decreased? What exactly is fetched rapidly?
parking52 samurang87 See the examples in #42 — there are few objects with few events (e.g. "mycrd-expr1"), of which only the latest is of our interest.
parking52 samurang87 This is efficiently an equivalent of this logic:
Except that:
threading.Queue().qsize()
on Mac OS (it is not supported), so I used to avoidqsize()
and just to not think about it. It is promised to work normally inasyncio.Queue
though.while queue.qsize() > 0:
is not a suitable criterion here, unlessfirst_time
is introduced. But it makes it same as not nice as double tries. In that case, it would look like this:The text was updated successfully, but these errors were encountered: