Run tasks at this end of cron execution and with_transaction
issue7781 review68391002
This commit is contained in:
1 parent
e5bf50805d
commit
31dc11cf6d
2 files changed
+9
No files matched your search
@@ -15,6 +15,7 @@ from ..transaction import Transaction
|
||||
from ..pool import Pool
|
||||
from ..config import config
|
||||
from ..sendmail import sendmail
|
||||
from trytond.worker import run_task
|
||||
|
||||
__all__ = [
|
||||
'Cron',
|
||||
@@ -184,3 +185,6 @@ class Cron(DeactivableMixin, ModelSQL, ModelView):
|
||||
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)
|
||||
@@ -124,6 +124,8 @@ def with_pool(func):
|
||||
|
||||
|
||||
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 @@ def with_transaction(readonly=None):
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user