changeset 69fa998ab9e8 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=69fa998ab9e8
description:
Run tasks at this end of cron execution and with_transaction
issue7781
review68391002
diffstat:
trytond/ir/cron.py | 4 ++++
trytond/protocols/wrappers.py | 5 +++++
2 files changed, 9 insertions(+), 0 deletions(-)
diffs (40 lines):
diff -r af815f679066 -r 69fa998ab9e8 trytond/ir/cron.py
--- a/trytond/ir/cron.py Sun Dec 30 00:21:39 2018 +0100
+++ b/trytond/ir/cron.py Sun Dec 30 00:22:41 2018 +0100
@@ -15,6 +15,7 @@
from ..pool import Pool
from ..config import config
from ..sendmail import sendmail
+from trytond.worker import run_task
__all__ = [
'Cron',
@@ -184,3 +185,6 @@
except Exception:
transaction.rollback()
logger.error('Running cron %s', cron.id, exc_info=True)
+ while transaction.tasks:
+ task_id = transaction.tasks.pop()
+ run_task(db_name, task_id)
diff -r af815f679066 -r 69fa998ab9e8 trytond/protocols/wrappers.py
--- a/trytond/protocols/wrappers.py Sun Dec 30 00:21:39 2018 +0100
+++ b/trytond/protocols/wrappers.py Sun Dec 30 00:22:41 2018 +0100
@@ -124,6 +124,8 @@
def with_transaction(readonly=None):
+ from trytond.worker import run_task
+
def decorator(func):
@wraps(func)
def wrapper(request, pool, *args, **kwargs):
@@ -152,6 +154,9 @@
raise
# Need to commit to unlock SQLite database
transaction.commit()
+ while transaction.tasks:
+ task_id = transaction.tasks.pop()
+ run_task(pool, task_id)
return result
return wrapper
return decorator