aiocache
aiocache copied to clipboard
Support Cython
I get this error : AttributeError: 'method_descriptor' object has no attribute 'module'
File "C:\Users\fff.conda\envs\biconome\lib\asyncio\base_events.py", line 579, in run_until_complete return future.result() File "C:\Users\fff.conda\envs\biconome\lib\site-packages\aiocache\decorators.py", line 73, in wrapper return await self.decorator(f, *args, **kwargs) File "C:\Users\fff.conda\envs\biconome\lib\site-packages\aiocache\decorators.py", line 79, in decorator key = self.get_cache_key(f, args, kwargs) File "C:\Users\fff.conda\envs\biconome\lib\site-packages\aiocache\decorators.py", line 99, in get_cache_key return self._key_from_args(f, args, kwargs) File "C:\Users\fff.conda\envs\biconome\lib\site-packages\aiocache\decorators.py", line 104, in _key_from_args args[1:] if self.noself else args) + str(ordered_kwargs) AttributeError: 'method_descriptor' object has no attribute 'module'
The version that I used is ' pip install aiocache==0.10.0' and ' aiocache-0.11.1'
`cdef class BaseMarket:
_CACHE_ = Cache()
cdef str symbol
cdef dict __dict__
@classmethod
async def http_request(cls, url, data=None,accept="json",timeout=1) -> any:
_timeout = aiohttp.ClientTimeout(total=timeout)
async with aiohttp.ClientSession(timeout=_timeout) as client:
try:
if data == None:
_temp_cache = await BaseMarket._CACHE_.get(key=f'res_data_{url}')
if _temp_cache:
res_data = _temp_cache
else:
async with client.get(url) as response:
await _CACHE_.add(key=f'res_data_{url}',value=res_data,ttl=1)
else:
_temp_cache = await _CACHE_.get(key=f'res_data_{url}_{accept}')
if _temp_cache:
res_data = _temp_cache
else:
async with client.post(url) as response:
response: aiohttp.ClientResponse = response
...
except TimeoutError as te:
print(f"Timeourt Error from {url} accurred <{str(te)}>")
cdef class SOMECLASSMarket(BaseMarket):
def __init__(self,
symbol: Optional[str] = None,
):
super().__init__()
self.symbol = symbol
@classmethod
def split_symbol(cls, symbol:str) -> Tuple[str,str]:
pass
@classmethod
def http_request(cls) -> any:
return SOMECLASSMarket.http_request(cls)
pass`
the code is like that
the Cython version is 'cython==0.29.5'
Hey sorry for the delay, I never tested compatibility with cython
. I guess the error is because of how the decorator introspects the arguments of the function and so. I you want to have a look to support Cython I'm happy to review :)