[issue35481] Run Tasks cannot Concurrent

Andrew Svetlov report at bugs.python.org
Thu Dec 13 08:30:45 EST 2018


Andrew Svetlov <andrew.svetlov at gmail.com> added the comment:

A task should have `await` inside to give to loop a chance to switch to another task (or get canceled).

It is not an asyncio bug but a part of specified behavior.

Your code could be modified as

async def readdev(dev):
    while True:
        buf=os.read(dev, 480)
        print([struct.unpack('llHHi', buf[i*24:(i+1)*24]) for i in range(len(buf)//24)])
        await asyncio.sleep(0)

to use tasks switching

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35481>
_______________________________________


More information about the Python-bugs-list mailing list