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

IndexError when exiting context manager #52

Open
maccinza opened this issue Mar 14, 2018 · 1 comment
Open

IndexError when exiting context manager #52

maccinza opened this issue Mar 14, 2018 · 1 comment

Comments

@maccinza
Copy link

I'm experiencing a similar IndexError in one of my api views when using itunesiap.env.sandbox context manager:

# ...
if sandbox:
    with itunesiap.env.sandbox:
        try:
            response = itunesiap.verify(raw_data, use_sandbox=True)
            return True, response
        except (ItunesServerNotAvailable, ItunesServerNotReachable):
            no_response = True
        except itunesiap.exc.InvalidReceipt as exc:
            error = exc.description

Sentry actually indicates the error/exception being raised when exiting the contextmanager:

itunesiap/environment.py in __exit__ at line 42
        self._ctx_id = len(self._stack)
        self.push()
        return self
    def __exit__(self, exc_type, exc_value, tb):
        self._stack.pop(self._ctx_id)  # this line

Any clues on what might be happening?

@youknowone
Copy link
Owner

Are you using multi-threaded or any async logics? itunesiap's context manager implementation is not safe for async jobs.
env param will help your problem. (You need recent version of itunesiap)

itunesiap.verify(raw_data, env=itunesiap.env.review)

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