Closed zhen0 closed 4 days ago
import asyncio import warnings from typing import Generic, TypeVar T = TypeVar("T") class AwaitableWrapper(Generic[T]): def __init__(self, value: T): self._value = value def __call__(self): return self._value def __await__(self): warnings.warn( "Awaiting this object is deprecated. It is now synchronous.", DeprecationWarning, stacklevel=2, ) return self._return_value().__await__() async def _return_value(self): return self._value # Example usage wrapped_value = AwaitableWrapper(42) result = wrapped_value() # Synchronous usage print(result) async def main(): async_result = await wrapped_value # Asynchronous usage with warning print(async_result) asyncio.run(main())
this was solved by #14197 - sorry @zhen0 I forgot to update the ticket