Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7343036
D1384.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D1384.diff
View Options
diff --git a/swh/core/db/__init__.py b/swh/core/db/__init__.py
--- a/swh/core/db/__init__.py
+++ b/swh/core/db/__init__.py
@@ -113,7 +113,7 @@
self.conn = conn
self.pool = pool
- def __del__(self):
+ def put_conn(self):
if self.pool:
self.pool.putconn(self.conn)
@@ -182,6 +182,7 @@
for k in columns]
f.write(','.join(line))
f.write('\n')
+
finally:
# No problem bubbling up exceptions, but we still need to make sure
# we finish copying, even though we're probably going to cancel the
diff --git a/swh/core/db/common.py b/swh/core/db/common.py
--- a/swh/core/db/common.py
+++ b/swh/core/db/common.py
@@ -43,9 +43,12 @@
return ret
else:
db = self.get_db()
- with db.transaction() as cur:
- apply_options(cur, __client_options)
- return meth(self, *args, db=db, cur=cur, **kwargs)
+ try:
+ with db.transaction() as cur:
+ apply_options(cur, __client_options)
+ return meth(self, *args, db=db, cur=cur, **kwargs)
+ finally:
+ self.put_db(db)
return _meth
return decorator
@@ -73,8 +76,12 @@
apply_options(cur, old_options)
else:
db = self.get_db()
- with db.transaction() as cur:
- apply_options(cur, __client_options)
- yield from meth(self, *args, db=db, cur=cur, **kwargs)
+ try:
+ with db.transaction() as cur:
+ apply_options(cur, __client_options)
+ yield from meth(self, *args, db=db, cur=cur, **kwargs)
+ finally:
+ self.put_db(db)
+
return _meth
return decorator
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mar 17 2025, 6:52 PM (7 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216474
Attached To
D1384: Explicitely give Db connections back to the pool.
Event Timeline
Log In to Comment