Skip to content

Conversation

@bpeterman
Copy link

@bpeterman bpeterman commented Jul 11, 2025

Problem

File "customerio/client_base.py", line 112, in _close

...
AttributeError: 'NoneType' object has no attribute 'close'

The _close() method in ClientBase was attempting to call .close() on self._current_session without checking if it was None first. This could lead to an AttributeError when:

  • Connection pooling is disabled (use_connection_pooling=False)
  • The session hasn't been initialized yet or has been set to None

Solution

Added a null check to the condition in _close() method to ensure we only attempt to close the session if it actually exists:

# Before
if (not self.use_connection_pooling):
    self._current_session.close()  # Could raise AttributeError if None

# After  
if (not self.use_connection_pooling and self._current_session is not None):
    self._current_session.close()  # Safe - only called when session exists

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 this pull request may close these issues.

2 participants