changeset a45d8d6c3365 in trytond:5.0
details: https://hg.tryton.org/trytond?cmd=changeset;node=a45d8d6c3365
description:
        Run tasks at this end of cron execution and with_transaction

        issue7781
        review68391002
        (grafted from 69fa998ab9e8b991d3462681ebcc7307e54e1ba6)
diffstat:

 trytond/ir/cron.py            |  4 ++++
 trytond/protocols/wrappers.py |  5 +++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diffs (40 lines):

diff -r 99f1b0a6f9bf -r a45d8d6c3365 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
@@ -14,6 +14,7 @@
 from ..pool import Pool
 from ..config import config
 from ..sendmail import sendmail
+from trytond.worker import run_task
 
 __all__ = [
     'Cron',
@@ -186,3 +187,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 99f1b0a6f9bf -r a45d8d6c3365 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

Reply via email to