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

Instance is not bound to a Session (nameko-sentry DP) #24

Closed
alexeysofin opened this issue Feb 28, 2018 · 0 comments · Fixed by #27
Closed

Instance is not bound to a Session (nameko-sentry DP) #24

alexeysofin opened this issue Feb 28, 2018 · 0 comments · Fixed by #27

Comments

@alexeysofin
Copy link

alexeysofin commented Feb 28, 2018

When using new interface inside some service method like this (taken from examples in README)

class Service(object):
    name = "service"

   db = Database(DeclarativeBase)
   sentry = SentryReporter()

    @entrypoint
    def write_to_db(self):
        model = Model(...)
        with self.db.get_session() as session:
            session.add(model)
            raise Exception()

if any exception is raised inside with block and service instance has nameko-sentry DP this will trigger
Instance <Model at 0x7fe4de51b240> is not bound to a Session when raven wants to stringify this object (repr wants instance's primary key) because the session is closed after context block is over.

Is there a reason to close a session in context manager?

Secondly there might be some misunderstanding from the documentation because it says

As a context manager that issues a commit or rollback on exit:

But not a word about that session is closed and all instances are invalidated.

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

Successfully merging a pull request may close this issue.

1 participant