-
-
Notifications
You must be signed in to change notification settings - Fork 255
Closed
Description
I was reading through the source code while doing a migration from python-snap7 version 1 to 2 and noticed this:
(docstring omitted for brevity)
@cache
def check_error(code: int, context: Context = "client") -> None:
if code and code != 1:
error = error_text(code, context)
logger.error(error)
raise RuntimeError(error)In the case of an error, this function raises an exception, which means there is no return value to cache. Therefore only the returning of None when code is 0 or 1 will be cached, but that's such a simple case to handle that I think caching might make things slower rather than faster.
Perhaps the error_text() function would be more suitable to apply @cache to?
Metadata
Metadata
Assignees
Labels
No labels