Merge pull request #771 from anandpdoshi/anand-august-12
[fix] Get Notification Deadlock
This commit is contained in:
commit
d61b3c69cf
6 changed files with 39 additions and 12 deletions
|
|
@ -7,8 +7,7 @@ globals attached to frappe module
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from werkzeug.local import Local, release_local
|
||||
import os, importlib, inspect
|
||||
import json
|
||||
import os, importlib, inspect, logging, json
|
||||
|
||||
# public
|
||||
from frappe.__version__ import __version__
|
||||
|
|
@ -639,3 +638,14 @@ def get_print_format(doctype, name, print_format=None, style=None, as_pdf=False)
|
|||
return html
|
||||
else:
|
||||
return html
|
||||
|
||||
logging_setup_complete = False
|
||||
def get_logger(module=None):
|
||||
from frappe.setup_logging import setup_logging
|
||||
global logging_setup_complete
|
||||
|
||||
if not logging_setup_complete:
|
||||
setup_logging()
|
||||
logging_setup_complete = True
|
||||
|
||||
return logging.getLogger(module or "frappe")
|
||||
|
|
|
|||
|
|
@ -20,15 +20,13 @@ import frappe.utils.response
|
|||
import frappe.website.render
|
||||
from frappe.utils import get_site_name
|
||||
from frappe.middlewares import StaticDataMiddleware
|
||||
from frappe.setup_logging import setup_logging
|
||||
|
||||
local_manager = LocalManager([frappe.local])
|
||||
|
||||
_site = None
|
||||
_sites_path = os.environ.get("SITES_PATH", ".")
|
||||
|
||||
setup_logging()
|
||||
logger = logging.getLogger(__name__)
|
||||
logger = frappe.get_logger()
|
||||
|
||||
@Request.application
|
||||
def application(request):
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import MySQLdb
|
||||
from frappe.model.document import Document
|
||||
|
||||
logger = frappe.get_logger()
|
||||
|
||||
class NotificationCount(Document):
|
||||
pass
|
||||
|
||||
|
|
@ -34,18 +37,34 @@ def get_notifications():
|
|||
result = frappe.get_list(d, fields=["count(*)"],
|
||||
filters=[[d, key, "=", condition[key]]], as_list=True)[0][0]
|
||||
|
||||
frappe.get_doc({"doctype":"Notification Count", "for_doctype":d,
|
||||
"open_count":result}).insert(ignore_permissions=True)
|
||||
|
||||
open_count_doctype[d] = result
|
||||
|
||||
try:
|
||||
frappe.get_doc({"doctype":"Notification Count", "for_doctype":d,
|
||||
"open_count":result}).insert(ignore_permissions=True)
|
||||
|
||||
except MySQLdb.OperationalError, e:
|
||||
if e.args[0] != 1213:
|
||||
raise
|
||||
|
||||
logger.error("Deadlock")
|
||||
|
||||
for m in config.for_module:
|
||||
if m in notification_count:
|
||||
open_count_module[m] = notification_count[m]
|
||||
else:
|
||||
open_count_module[m] = frappe.get_attr(config.for_module[m])()
|
||||
frappe.get_doc({"doctype":"Notification Count", "for_doctype":m,
|
||||
"open_count":open_count_module[m]}).insert(ignore_permissions=True)
|
||||
|
||||
try:
|
||||
frappe.get_doc({"doctype":"Notification Count", "for_doctype":m,
|
||||
"open_count":open_count_module[m]}).insert(ignore_permissions=True)
|
||||
|
||||
except MySQLdb.OperationalError, e:
|
||||
if e.args[0] != 1213:
|
||||
raise
|
||||
|
||||
logger.error("Deadlock")
|
||||
|
||||
|
||||
return {
|
||||
"open_count_doctype": open_count_doctype,
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -35,7 +35,7 @@ def setup_logging():
|
|||
}
|
||||
},
|
||||
"loggers": {
|
||||
"frappe.app": {
|
||||
"frappe": {
|
||||
"level": "INFO",
|
||||
"propagate": False,
|
||||
"filters": ["context_filter"],
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class EMail:
|
|||
Also provides a clean way to add binary `FileData` attachments
|
||||
Also sets all messages as multipart/alternative for cleaner reading in text-only clients
|
||||
"""
|
||||
def __init__(self, sender='', recipients=[], subject='', alternative=0, reply_to=None):
|
||||
def __init__(self, sender='', recipients=(), subject='', alternative=0, reply_to=None):
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email import Charset
|
||||
Charset.add_charset('utf-8', Charset.QP, Charset.QP, 'utf-8')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue