mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-30 17:50:46 +00:00
utils/asyn: Ensure _AsyncPolymorphicFunction is not detected as a coroutine function
inspect.iscoroutinefunction() currently detects _AsyncPolymorphicFunction() as being a coroutine function since it inspects x.__code__.co_flags to determine so. Since we delegate attribute access to the async function, it makes _AsyncPolymorphicFunction() appear as being a coroutine function even though it is not. Fix that by directing __code__ attribute access to __call__'s code.
This commit is contained in:
parent
b6da67d12f
commit
8773c10424
@ -217,6 +217,12 @@ class _AsyncPolymorphicFunction:
|
||||
blocking=self.blocking.__get__(*args, **kwargs),
|
||||
)
|
||||
|
||||
# Ensure inspect.iscoroutinefunction() does not detect us as being async,
|
||||
# since __call__ is not.
|
||||
@property
|
||||
def __code__(self):
|
||||
return self.__call__.__code__
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self.blocking(*args, **kwargs)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user