feat: nowait to skip blocking locks
This commit is contained in:
parent
8f00aae160
commit
e810fb7eca
2 changed files with 12 additions and 1 deletions
|
|
@ -474,6 +474,7 @@ class Database:
|
|||
pluck=False,
|
||||
distinct=False,
|
||||
skip_locked=False,
|
||||
wait=True,
|
||||
):
|
||||
"""Return a document property or list of properties.
|
||||
|
||||
|
|
@ -488,6 +489,7 @@ class Database:
|
|||
:param pluck: pluck first column instead of returning as nested list or dict.
|
||||
:param for_update: All the affected/read rows will be locked.
|
||||
:param skip_locked: Skip selecting currently locked rows.
|
||||
:param wait: Wait for aquiring lock
|
||||
|
||||
Example:
|
||||
|
||||
|
|
@ -519,6 +521,7 @@ class Database:
|
|||
distinct=distinct,
|
||||
limit=1,
|
||||
skip_locked=skip_locked,
|
||||
wait=wait,
|
||||
)
|
||||
|
||||
if not run:
|
||||
|
|
@ -552,6 +555,7 @@ class Database:
|
|||
distinct=False,
|
||||
limit=None,
|
||||
skip_locked=False,
|
||||
wait=True,
|
||||
):
|
||||
"""Return multiple document properties.
|
||||
|
||||
|
|
@ -592,6 +596,7 @@ class Database:
|
|||
limit=limit,
|
||||
as_dict=as_dict,
|
||||
skip_locked=skip_locked,
|
||||
wait=True,
|
||||
for_update=for_update,
|
||||
)
|
||||
|
||||
|
|
@ -619,6 +624,7 @@ class Database:
|
|||
limit=limit,
|
||||
for_update=for_update,
|
||||
skip_locked=skip_locked,
|
||||
wait=wait,
|
||||
)
|
||||
except Exception as e:
|
||||
if ignore and (
|
||||
|
|
@ -856,6 +862,7 @@ class Database:
|
|||
update=None,
|
||||
for_update=False,
|
||||
skip_locked=False,
|
||||
wait=True,
|
||||
run=True,
|
||||
pluck=False,
|
||||
distinct=False,
|
||||
|
|
@ -867,6 +874,7 @@ class Database:
|
|||
order_by=order_by,
|
||||
for_update=for_update,
|
||||
skip_locked=skip_locked,
|
||||
wait=wait,
|
||||
fields=fields,
|
||||
distinct=distinct,
|
||||
limit=limit,
|
||||
|
|
@ -892,6 +900,7 @@ class Database:
|
|||
as_dict=False,
|
||||
for_update=False,
|
||||
skip_locked=False,
|
||||
wait=True,
|
||||
):
|
||||
if names := list(filter(None, names)):
|
||||
return frappe.qb.get_query(
|
||||
|
|
@ -904,6 +913,7 @@ class Database:
|
|||
validate_filters=True,
|
||||
for_update=for_update,
|
||||
skip_locked=skip_locked,
|
||||
wait=wait,
|
||||
).run(debug=debug, run=run, as_dict=as_dict, pluck=pluck)
|
||||
return {}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ class Engine:
|
|||
*,
|
||||
validate_filters: bool = False,
|
||||
skip_locked: bool = False,
|
||||
wait: bool = True,
|
||||
) -> QueryBuilder:
|
||||
self.is_mariadb = frappe.db.db_type == "mariadb"
|
||||
self.is_postgres = frappe.db.db_type == "postgres"
|
||||
|
|
@ -84,7 +85,7 @@ class Engine:
|
|||
self.query = self.query.distinct()
|
||||
|
||||
if for_update:
|
||||
self.query = self.query.for_update(skip_locked=skip_locked)
|
||||
self.query = self.query.for_update(skip_locked=skip_locked, nowait=not wait)
|
||||
|
||||
if group_by:
|
||||
self.query = self.query.groupby(group_by)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue