Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Cython #466

Open
fingerecho opened this issue Oct 12, 2019 · 3 comments
Open

Support Cython #466

fingerecho opened this issue Oct 12, 2019 · 3 comments

Comments

@fingerecho
Copy link

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'

@fingerecho
Copy link
Author

`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

@fingerecho
Copy link
Author

the Cython version is 'cython==0.29.5'

@argaen
Copy link
Member

argaen commented Dec 5, 2019

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 :)

@Dreamsorcerer Dreamsorcerer changed the title AttributeError: 'method_descriptor' object has no attribute '__module__' Support Cython Jan 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants