Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] fixes event priority level & memory leak #26872

Merged
merged 2 commits into from
May 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/controller/python/chip/clusters/Attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class EventTimestampType(Enum):

@unique
class EventPriority(Enum):
DEBUG = 1
INFO = 2
CRITICAL = 3
DEBUG = 0
INFO = 1
CRITICAL = 2


@dataclass
Expand Down Expand Up @@ -535,7 +535,7 @@ def Callback(transaction: SubscriptionTransaction, errorEncountered: int, nextRe
self._onResubscriptionAttemptedCb = callback
self._onResubscriptionAttemptedCb_isAsync = isAsync

def SetResubscriptionSucceededCallback(self, callback: Callback[[SubscriptionTransaction], None], isAsync=False):
def SetResubscriptionSucceededCallback(self, callback: Callable[[SubscriptionTransaction], None], isAsync=False):
'''
Sets the callback function that gets invoked when a re-subscription attempt succeeds. The callback
is expected to have the following signature:
Expand Down Expand Up @@ -886,8 +886,13 @@ def _OnReadAttributeDataCallback(closure, dataVersion: int, endpoint: int, clust
def _OnReadEventDataCallback(closure, endpoint: int, cluster: int, event: c_uint64, number: int, priority: int, timestamp: int, timestampType: int, data, len, status):
dataBytes = ctypes.string_at(data, len)
path = EventPath(ClusterId=cluster, EventId=event)
closure.handleEventData(EventHeader(
EndpointId=endpoint, ClusterId=cluster, EventId=event, EventNumber=number, Priority=EventPriority(priority), Timestamp=timestamp, TimestampType=EventTimestampType(timestampType)), path, dataBytes[:], status)

# EventHeader is valid only when successful
eventHeader = None
if status == chip.interaction_model.Status.Success.value:
eventHeader = EventHeader(
EndpointId=endpoint, ClusterId=cluster, EventId=event, EventNumber=number, Priority=EventPriority(priority), Timestamp=timestamp, TimestampType=EventTimestampType(timestampType))
closure.handleEventData(eventHeader, path, dataBytes[:], status)


@_OnSubscriptionEstablishedCallbackFunct
Expand Down Expand Up @@ -1079,10 +1084,6 @@ def Read(future: Future, eventLoop, device, devCtrl, attributes: List[AttributeP
path = chip.interaction_model.EventPathIBstruct.build(path)
readargs.append(ctypes.c_char_p(path))

ctypes.pythonapi.Py_IncRef(ctypes.py_object(transaction))
minInterval = 0
maxInterval = 0

readClientObj = ctypes.POINTER(c_void_p)()
readCallbackObj = ctypes.POINTER(c_void_p)()

Expand Down