mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-07-15 17:22:41 +02:00
feat(tasks): add error logging
This commit is contained in:
@@ -1,10 +1,16 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
from procrastinate import builtin_tasks
|
from procrastinate import builtin_tasks
|
||||||
from procrastinate.contrib.django import app
|
from procrastinate.contrib.django import app
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@app.periodic(cron="0 4 * * *")
|
@app.periodic(cron="0 4 * * *")
|
||||||
@app.task(queueing_lock="remove_old_jobs", pass_context=True)
|
@app.task(queueing_lock="remove_old_jobs", pass_context=True)
|
||||||
async def remove_old_jobs(context, timestamp):
|
async def remove_old_jobs(context, timestamp):
|
||||||
|
try:
|
||||||
return await builtin_tasks.remove_old_jobs(
|
return await builtin_tasks.remove_old_jobs(
|
||||||
context,
|
context,
|
||||||
max_hours=744,
|
max_hours=744,
|
||||||
@@ -12,3 +18,9 @@ async def remove_old_jobs(context, timestamp):
|
|||||||
remove_cancelled=True,
|
remove_cancelled=True,
|
||||||
remove_aborted=True,
|
remove_aborted=True,
|
||||||
)
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(
|
||||||
|
"Error while executing 'remove_old_jobs' task",
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
raise e
|
||||||
|
|||||||
+13
-1
@@ -1,4 +1,6 @@
|
|||||||
from cachalot.api import cachalot_disabled, invalidate
|
import logging
|
||||||
|
|
||||||
|
from cachalot.api import cachalot_disabled
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from procrastinate.contrib.django import app
|
from procrastinate.contrib.django import app
|
||||||
from simpleeval import EvalWithCompoundTypes
|
from simpleeval import EvalWithCompoundTypes
|
||||||
@@ -13,11 +15,15 @@ from apps.transactions.models import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
def check_for_transaction_rules(
|
def check_for_transaction_rules(
|
||||||
instance_id: int,
|
instance_id: int,
|
||||||
signal,
|
signal,
|
||||||
):
|
):
|
||||||
|
try:
|
||||||
with cachalot_disabled():
|
with cachalot_disabled():
|
||||||
|
|
||||||
instance = Transaction.objects.get(id=instance_id)
|
instance = Transaction.objects.get(id=instance_id)
|
||||||
@@ -147,3 +153,9 @@ def check_for_transaction_rules(
|
|||||||
instance.entities.add(entity)
|
instance.entities.add(entity)
|
||||||
|
|
||||||
instance.save()
|
instance.save()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(
|
||||||
|
"Error while executing 'check_for_transaction_rules' task",
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
raise e
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
from procrastinate.contrib.django import app
|
from procrastinate.contrib.django import app
|
||||||
|
|
||||||
from apps.transactions.models import RecurringTransaction
|
from apps.transactions.models import RecurringTransaction
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@app.periodic(cron="0 0 * * *")
|
@app.periodic(cron="0 0 * * *")
|
||||||
@app.task
|
@app.task
|
||||||
def generate_recurring_transactions(timestamp=None):
|
def generate_recurring_transactions(timestamp=None):
|
||||||
|
try:
|
||||||
RecurringTransaction.generate_upcoming_transactions()
|
RecurringTransaction.generate_upcoming_transactions()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(
|
||||||
|
"Error while executing 'generate_recurring_transactions' task",
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
raise e
|
||||||
|
|||||||
Reference in New Issue
Block a user