diff --git a/frappe/desk/doctype/notification_log/notification_log.py b/frappe/desk/doctype/notification_log/notification_log.py index 70f31606c1..8793559611 100644 --- a/frappe/desk/doctype/notification_log/notification_log.py +++ b/frappe/desk/doctype/notification_log/notification_log.py @@ -93,6 +93,7 @@ def enqueue_create_notification(users: list[str] | str, doc: dict): doc=doc, users=users, now=frappe.flags.in_test, + enqueue_after_commit=not frappe.flags.in_test, ) diff --git a/frappe/model/document.py b/frappe/model/document.py index 9a0ea809bb..72a491d039 100644 --- a/frappe/model/document.py +++ b/frappe/model/document.py @@ -458,7 +458,7 @@ class Document(BaseDocument): d: Document d.db_update() - def get_doc_before_save(self) -> "Document": + def get_doc_before_save(self) -> "Self": return getattr(self, "_doc_before_save", None) def has_value_changed(self, fieldname): diff --git a/frappe/utils/background_jobs.py b/frappe/utils/background_jobs.py index 815145ef70..4e2a7c71b9 100644 --- a/frappe/utils/background_jobs.py +++ b/frappe/utils/background_jobs.py @@ -163,7 +163,7 @@ def enqueue( def enqueue_call(): return q.enqueue_call( - execute_job, + "frappe.utils.background_jobs.execute_job", on_success=Callback(func=on_success) if on_success else None, on_failure=Callback(func=on_failure) if on_failure else None, timeout=timeout, diff --git a/frappe/utils/redis_wrapper.py b/frappe/utils/redis_wrapper.py index c38f54a2f2..e494d07bab 100644 --- a/frappe/utils/redis_wrapper.py +++ b/frappe/utils/redis_wrapper.py @@ -2,6 +2,7 @@ # License: MIT. See LICENSE import pickle import re +from contextlib import suppress import redis from redis.commands.search import Search @@ -62,14 +63,8 @@ class RedisWrapper(redis.Redis): if not expires_in_sec: frappe.local.cache[key] = val - try: - if expires_in_sec: - self.setex(name=key, time=expires_in_sec, value=pickle.dumps(val)) - else: - self.set(key, pickle.dumps(val)) - - except redis.exceptions.ConnectionError: - return None + with suppress(redis.exceptions.ConnectionError): + self.set(name=key, value=pickle.dumps(val), ex=expires_in_sec) def get_value(self, key, generator=None, user=None, expires=False, shared=False): """Return cache value. If not found and generator function is