-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
[vdsql-] ensure each thread in vdsql tracks its single connection #2704
base: develop
Are you sure you want to change the base?
Conversation
else: | ||
r = self.pool.pop(0) | ||
|
||
with self._lock: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this lock if we're just putting things on threading.local() anyway? Do we have to even have a _local
member or can we just use threading.local()
each time?
pass | ||
|
||
def close_all(self): | ||
if hassattr(self._local, 'connection'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must not have been tested because hassattr
is mispelled.
|
||
@contextmanager | ||
def get_conn(self): | ||
if not self.pool: | ||
if not hasattr(self._local, 'connection'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer getattr
to hasattr
.
Uses threading.local to keep track of a thread's connection.
Otherwise, you occassionally get this error when opening an SQLite table with
vdsql
: