trevorhobenshield / twitter-api-client

Implementation of X/Twitter v1, v2, and GraphQL APIs
https://pypi.org/project/twitter-api-client
MIT License
1.56k stars 207 forks source link

call stack is not deep enough #203

Closed theicfire closed 5 months ago

theicfire commented 5 months ago

This code is unused but causes an error for me:

        try:
            fn_name = sys._getframe(9).f_code.co_name
            self.rate_limits[fn_name] = {'_endpoint': name} | {k: int(v) for k, v in r.headers.items() if 'rate-limit' in k}
        except Exception as e:
            self.logger.debug(f'{e}')

When I run simple examples, I get "call stack is not deep enough"

Fwiw, I ran this in the try block:

            for i in range(9):
                print('call stack name:', sys._getframe(i).f_code.co_name)

And got:

call stack name: _query
call stack name: _paginate
call stack name: wrap_awaitable
call stack name: run
call stack name: run
call stack name: _run
call stack name: users
call stack name: <module>

But I'm not sure what the purpose of this is because the rate_limits member is unused anyways.

trevorhobenshield commented 5 months ago

But I'm not sure what the purpose of this is because the rate_limits member is unused anyways.

a few people have asked me to add this, rate_limits is just property which tracks the current status of the rate limit for a specific gql op.

When I run simple examples, I get "call stack is not deep enough"

not sure why i did that, hard-coding an index in the call stack isn't ideal. anyways, it's changed now. shouldn't be any more issues!

theicfire commented 5 months ago

Sweet, thanks!