1

I am writing a python program to scan a QRcode and exit or if the QR is not read passed X seconds the program needs to end.

import asyncio
from camera.QRGetter import QRGetter


async def getQR(qr_reader):
    data = await qr_reader.getQRData()
    print(data)

async def main():
    qr_reader = QRGetter()
    try:
        await asyncio.wait_for(getQR(qr_reader), timeout=5.0)
    except asyncio.TimeoutError:
        qr_reader.close()
        print('timeout!')


asyncio.run(main())

The class QRGetter works fine without error. Inside it there is a while for iterate frame to frame the camera input. If the QR is showed, it return the data and exit correctly.

The main problem is that the timeout didn't trigger.

How can I fix it ? How can I fix

I waited two minutes, and the timeout didn't trigger

0 Answers0