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

chore: fix session pool del before lock #367

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wey-gu
Copy link
Contributor

@wey-gu wey-gu commented Oct 22, 2024

tests/test_session_pool.py::test_session_pool_multi_thread

tests/test_session_pool.py::TestSessionPoolBasic::test_pool_init
  /home/runner/work/nebula-python/nebula-python/.venv/lib/python3.12/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <function SessionPool.__del__ at 0x7f7fff215760>

  Traceback (most recent call last):
    File "/home/runner/work/nebula-python/nebula-python/nebula3/gclient/net/SessionPool.py", line 73, in __del__
      self.close()
    File "/home/runner/work/nebula-python/nebula-python/nebula3/gclient/net/SessionPool.py", line 329, in close
      with self._lock:
           ^^^^^^^^^^
  AttributeError: 'SessionPool' object has no attribute '_lock'

tests/test_session_pool.py::test_session_pool_multi_thread

tests/test_session_pool.py::TestSessionPoolBasic::test_pool_init
  /home/runner/work/nebula-python/nebula-python/.venv/lib/python3.12/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <function SessionPool.__del__ at 0x7f7fff215760>

  Traceback (most recent call last):
    File "/home/runner/work/nebula-python/nebula-python/nebula3/gclient/net/SessionPool.py", line 73, in __del__
      self.close()
    File "/home/runner/work/nebula-python/nebula-python/nebula3/gclient/net/SessionPool.py", line 329, in close
      with self._lock:
           ^^^^^^^^^^
  AttributeError: 'SessionPool' object has no attribute '_lock'
@wey-gu
Copy link
Contributor Author

wey-gu commented Oct 22, 2024

0919c79 fixed the ci on py37, this should be fine as we have test coverage running over 3.7 w/o PDM already, plus PDM now is 3.8+ actually.

@@ -52,7 +52,7 @@ jobs:
strategy:
max-parallel: 2
matrix:
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
python-version: [3.8, 3.9, '3.10', 3.11]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be fine as we have test coverage running over 3.7 w/o PDM already, plus PDM now is 3.8+ actually.

@@ -70,7 +70,8 @@ def __init__(self, username, password, space_name, addresses):
self._close = False

def __del__(self):
self.close()
if hasattr(self, '_lock'):
self.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the root cause is when init the pool if the address is invalid, would raise exception
so the object has no _lock property.

prefer move the exception at the end of init function
and the every object has _lock property.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the current change it's also ok for me.
there's the same issue with meta client, please fix it in the same way

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.

3 participants