Debian Codegraph @

bindings/python/gpiod/internal.py

raw symbols SCIP
1 # SPDX-License-Identifier: GPL-2.0-or-later
2 # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <[email protected]>
3
4 from datetime import timedelta
5 from select import select
6 from typing import Optional, Union
7
8 __all__ = []
9
10
11 def poll_fd(fd: int, timeout: Optional[Union[timedelta, float]] = None) -> bool:
12 if isinstance(timeout, timedelta):
13 sec = timeout.total_seconds()
14 else:
15 sec = timeout
16
17 readable, _, _ = select([fd], [], [], sec)
18 return True if fd in readable else False