1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-25 12:39:18 +03:00
Files
libgpiod/bindings/python/gpiod/info_event.py
Vincent Fazio c9378d6c63 bindings: python: support free-threaded CPython
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>
2026-05-28 10:59:30 +02:00

45 lines
1.4 KiB
Python

# SPDX-License-Identifier: LGPL-2.1-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
from dataclasses import dataclass
from enum import Enum
from . import _ext
from .line_info import LineInfo
__all__ = ["InfoEvent"]
@dataclass(frozen=True, init=False, repr=False)
class InfoEvent:
"""
Immutable object containing data about a single line info event.
Synchronization: none required
"""
class Type(Enum):
"""Line status change event types."""
LINE_REQUESTED = _ext.INFO_EVENT_TYPE_LINE_REQUESTED
"""Line has been requested."""
LINE_RELEASED = _ext.INFO_EVENT_TYPE_LINE_RELEASED
"""Previously requested line has been released."""
LINE_CONFIG_CHANGED = _ext.INFO_EVENT_TYPE_LINE_CONFIG_CHANGED
"""Line configuration has changed."""
event_type: Type
"""Event type of the status change event."""
timestamp_ns: int
"""Timestamp of the event."""
line_info: LineInfo
"""Snapshot of line-info associated with the event."""
def __init__(self, event_type: int, timestamp_ns: int, line_info: LineInfo):
object.__setattr__(self, "event_type", InfoEvent.Type(event_type))
object.__setattr__(self, "timestamp_ns", timestamp_ns)
object.__setattr__(self, "line_info", line_info)
def __str__(self) -> str:
return f"<InfoEvent type={self.event_type} timestamp_ns={self.timestamp_ns} line_info={self.line_info}>"