Skip to content

Session is not set in object if connection fails, which raises 'AttributeError' on __del__ #746

Description

@tomasfarias

The session attribute is set on the Connection here:

self.session = Session(
.

If connecting fails (e.g. due to invalid host or credentials) then no session attribute will be set, but __del__ will still be called when the not-fully-initialized Connection instance is destroyed. This causes warnings to be printed to stderr.

A simple fix would be to check if session is set in open or doing the same thing in __del__ only, to keep the semantics of open intact.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineer-botMaintainer-applied gate: triggers engineer-bot (bug-fix on issue / take-over on PR).

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions