Skip to content

timeout read_loop? #201

Open
Open

Description

@martin-flower

This project is very helpful in enabling my python program to read input from a barcode reader whilst running as a cron job on reboot.

I would like to timeout the read_loop, after say 5 seconds, rather than wait forever for input which might never come.

Is this do-able?

Activity

  1. sezanzeb commented on Nov 18, 2023

    @sezanzeb
    Collaborator

    I haven't tried it, but you might have luck with something like

    event = asyncio.wait_for(input.async_read_one(), timeout=5)

    which should raise an exception after the timeout, or

    select.select([input.fd], [], [], 5)
    event = input.read_one()

    which should be None after the timeout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions