mirror of
https://github.com/xcat2/confluent.git
synced 2026-09-02 15:36:05 +00:00
Stop the aiohmi event loop from spinning when it has nothing to do
Command.eventloop called wait_for_rsp with no timeout. With nothing waiting or being kept alive there is no deadline to derive one from, so it returns without suspending and the loop runs flat out, measured at over 100000 iterations in two tenths of a second. MAX_IDLE gives it something to wait on, as a ceiling rather than a fixed delay: real deadlines still shorten it and an arriving packet still ends it early.
This commit is contained in:
@@ -209,7 +209,12 @@ class Command(object):
|
||||
@classmethod
|
||||
async def eventloop(cls):
|
||||
while True:
|
||||
await session.Session.wait_for_rsp()
|
||||
# A ceiling rather than no timeout at all: with nothing waiting or
|
||||
# being kept alive, wait_for_rsp has nothing to wait on and returns
|
||||
# at once, which would make this a busy loop. Sessions still shorten
|
||||
# it to their own deadlines, and an arriving packet still ends the
|
||||
# wait early.
|
||||
await session.Session.wait_for_rsp(timeout=session.MAX_IDLE)
|
||||
|
||||
@classmethod
|
||||
async def wait_for_rsp(cls, timeout):
|
||||
|
||||
Reference in New Issue
Block a user