On Wed, Aug 18, 2021 at 3:36 PM John Snow wrote: > On Tue, Aug 17, 2021 at 3:07 PM Niteesh G. S. > wrote: > >> On Tue, Aug 17, 2021 at 10:21 AM John Snow wrote: >> >>> On Fri, Jul 30, 2021 at 4:19 PM G S Niteesh Babu >>> wrote: >>> >> > Is this required? I would have hoped that after calling disconnect that >>> the state would have again changed to IDLE and you wouldn't need this >>> clause here. >>> >> After you mentioned it I too felt it was redundant. But on removing it >> the whole app freezes when trying to exit. >> I logged the state after the call to disconnect, instead of being in the >> IDLE state, it is still in DISCONNECTING state. >> I suspect this results in the constant infinite looping which doesn't >> give other coroutines a chance to run and blocks >> the event loop thus resulting in the freezing of the app. But I am not >> sure why the state isn't changing to IDLE. >> > > Hmm ... That may well be a bug in AQMP then. I will investigate. > No, it's not -- It's just tricky. The "problem" is that the runstate_changed() event only returns once the runstate has changed *after* you await it. So this code is perfectly correct and I am just bad at reading. --js