mirror of
https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
synced 2026-10-25 12:39:18 +03:00
PEP 703 [0] discusses making the GIL optional in certain builds of the CPython interpreter. This build option was available experiementally in Python 3.13 but has since been stabilized in Python 3.14 per PEP 779 [1]. According to the porting guide [2], there is no strict requirement that C extensions must be thread-safe. Experiments have shown that no logic changes are required if callers use sychronization mechanisms provided by the Python standard library. The documentation has been updated to call this out specifically using terminology from the porting guide [3]. [0]: https://peps.python.org/pep-0703/ [1]: https://peps.python.org/pep-0779/ [2]: https://py-free-threading.github.io/porting/#define-and-document-thread-safety-guarantees [3]: https://py-free-threading.github.io/documentation-principles/#free-threading-terminology Signed-off-by: Vincent Fazio <vfazio@gmail.com> Link: https://patch.msgid.link/20260527215922.18678-3-vfazio@gmail.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
90 lines
2.7 KiB
Python
90 lines
2.7 KiB
Python
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
|
|
|
|
from dataclasses import dataclass
|
|
from datetime import timedelta
|
|
|
|
from .line import Bias, Clock, Direction, Drive, Edge
|
|
|
|
__all__ = ["LineInfo"]
|
|
|
|
|
|
@dataclass(frozen=True, init=False, repr=False)
|
|
class LineInfo:
|
|
"""
|
|
Immutable snapshot of a line's status.
|
|
|
|
Synchronization: none required
|
|
"""
|
|
|
|
offset: int
|
|
"""Offset of the line."""
|
|
name: str
|
|
"""Name of the line."""
|
|
used: bool
|
|
"""Indicates whether line is in use."""
|
|
consumer: str
|
|
"""Name of the consumer of the line."""
|
|
direction: Direction
|
|
"""Direction setting of the line."""
|
|
active_low: bool
|
|
"""Active-low setting of the line."""
|
|
bias: Bias
|
|
"""Bias setting of the line."""
|
|
drive: Drive
|
|
"""Drive setting of the line."""
|
|
edge_detection: Edge
|
|
"""Edge detection setting of the line."""
|
|
event_clock: Clock
|
|
"""Event clock setting used for edge event timestamps for the line."""
|
|
debounced: bool
|
|
"""Indicates whether line is debounced."""
|
|
debounce_period: timedelta
|
|
"""Debounce period of the line."""
|
|
|
|
def __init__(
|
|
self,
|
|
offset: int,
|
|
name: str,
|
|
used: bool,
|
|
consumer: str,
|
|
direction: int,
|
|
active_low: bool,
|
|
bias: int,
|
|
drive: int,
|
|
edge_detection: int,
|
|
event_clock: int,
|
|
debounced: bool,
|
|
debounce_period_us: int,
|
|
):
|
|
object.__setattr__(self, "offset", offset)
|
|
object.__setattr__(self, "name", name)
|
|
object.__setattr__(self, "used", used)
|
|
object.__setattr__(self, "consumer", consumer)
|
|
object.__setattr__(self, "direction", Direction(direction))
|
|
object.__setattr__(self, "active_low", active_low)
|
|
object.__setattr__(self, "bias", Bias(bias))
|
|
object.__setattr__(self, "drive", Drive(drive))
|
|
object.__setattr__(self, "edge_detection", Edge(edge_detection))
|
|
object.__setattr__(self, "event_clock", Clock(event_clock))
|
|
object.__setattr__(self, "debounced", debounced)
|
|
object.__setattr__(
|
|
self, "debounce_period", timedelta(microseconds=debounce_period_us)
|
|
)
|
|
|
|
def __str__(self) -> str:
|
|
return '<LineInfo offset={} name="{}" used={} consumer="{}" direction={} active_low={} bias={} drive={} edge_detection={} event_clock={} debounced={} debounce_period={}>'.format( # noqa: UP032
|
|
self.offset,
|
|
self.name,
|
|
self.used,
|
|
self.consumer,
|
|
self.direction,
|
|
self.active_low,
|
|
self.bias,
|
|
self.drive,
|
|
self.edge_detection,
|
|
self.event_clock,
|
|
self.debounced,
|
|
self.debounce_period,
|
|
)
|