How to fail a task without logging an exception #478
Unanswered
davidolrik
asked this question in
Q&A
Replies: 2 comments 2 replies
-
I think there's currently no way to do that. What would you think would be a good API for this ? |
Beta Was this translation helpful? Give feedback.
2 replies
-
You could write a log Filter and install it on the logger. The filter would let you examine the message and choose to omit it on arbitrary conditions. Code from the top of my head, not tested: class OmitErrorFilter(logging.Filter):
def filter(self, record: logging.LogRecord) -> bool:
return getattr(record, "action", "") == "job_error" and replace_this_with_your_custom_conditions
logging.getLogger("procrastinate").addFilter(OmitErrorFilter()) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to set a task to
failed
from within the task it self.I can do this by throwing an Exception, but that will also output the full exception to the log which I would like to avoid.
From reading the code, it looks like there is no way to avoid this as it is now, or am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions