You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The register controller's context manager is added so that with can be used during field / register access to make mutex handling easier. However, the current code simply returns the mutex ownership after the yield:
@contextmanagerdefacquire(self, blocking=True, timeout=-1):
# Grab the lock with the supplied settingsresult=self._register_mutex.acquire(blocking=blocking, timeout=timeout)
# Allow the caller to execute their 'with'. 'result' is needed so that# if the lock cannot be grabbed the user can handle it.yieldresult# Release the lock, if it was actually acquiredifresult:
self._register_mutex.release()
This means that if there is an exception thrown within the yield, it skips the mutex release and the caller will permanently own the resource.
The yield should be surrounded with a try...except that will release the mutex before raising the exception so as not to mask it.
The register controller's context manager is added so that
with
can be used during field / register access to make mutex handling easier. However, the current code simply returns the mutex ownership after the yield:This means that if there is an exception thrown within the
yield
, it skips the mutex release and the caller will permanently own the resource.The
yield
should be surrounded with atry...except
that will release the mutex before raising the exception so as not to mask it.This was encountered in https://github.com/stfc-aeg/babyd-embedded/issues/7
The text was updated successfully, but these errors were encountered: