Merge pull request #3889 from wisp3rwind/pr_fix_repr_deadlock

Avoid deadlocks in Item.__repr__
This commit is contained in:
Benedikt 2021-03-18 22:39:30 +01:00 committed by GitHub
commit 8353c831d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -617,6 +617,16 @@ class Item(LibModel):
return self._cached_album[key]
raise
def __repr__(self):
# This must not use `with_album=True`, because that might access
# the database. When debugging, that is not guaranteed to succeed, and
# can even deadlock due to the database lock.
return '{0}({1})'.format(
type(self).__name__,
', '.join('{0}={1!r}'.format(k, self[k])
for k in self.keys(with_album=False)),
)
def keys(self, computed=False, with_album=True):
"""Get a list of available field names. `with_album`
controls whether the album's fields are included.