Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7450700
common.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1011 B
Subscribers
None
common.py
View Options
# Copyright (C) 2015-2016 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import
functools
def
db_transaction
(
meth
):
"""decorator to execute Storage methods within DB transactions
The decorated method must accept a `cur` keyword argument
"""
@functools.wraps
(
meth
)
def
_meth
(
self
,
*
args
,
**
kwargs
):
with
self
.
db
.
transaction
()
as
cur
:
return
meth
(
self
,
*
args
,
cur
=
cur
,
**
kwargs
)
return
_meth
def
db_transaction_generator
(
meth
):
"""decorator to execute Storage methods within DB transactions, while
returning a generator
The decorated method must accept a `cur` keyword argument
"""
@functools.wraps
(
meth
)
def
_meth
(
self
,
*
args
,
**
kwargs
):
with
self
.
db
.
transaction
()
as
cur
:
yield from
meth
(
self
,
*
args
,
cur
=
cur
,
**
kwargs
)
return
_meth
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Thu, Apr 17, 8:23 AM (4 d, 15 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3282394
Attached To
rDSTOC swh-storage-cassandra
Event Timeline
Log In to Comment