Added bench command to start worker
Added logger entry for RQ Added queue and timeout as arguments for email
This commit is contained in:
parent
6d0563e8ea
commit
a41c836d61
4 changed files with 19 additions and 11 deletions
9
frappe/commands.py
Normal file → Executable file
9
frappe/commands.py
Normal file → Executable file
|
|
@ -1009,6 +1009,12 @@ def get_version():
|
|||
if hasattr(module, "__version__"):
|
||||
print "{0} {1}".format(m, module.__version__)
|
||||
|
||||
|
||||
@click.command('start-worker')
|
||||
def start_rq_worker():
|
||||
from frappe.utils.background_jobs import start_worker
|
||||
start_worker()
|
||||
|
||||
# commands = [
|
||||
# new_site,
|
||||
# restore,
|
||||
|
|
@ -1074,5 +1080,6 @@ commands = [
|
|||
drop_site,
|
||||
set_config,
|
||||
get_version,
|
||||
new_language
|
||||
new_language,
|
||||
start_rq_worker,
|
||||
]
|
||||
|
|
|
|||
2
frappe/core/doctype/communication/email.py
Normal file → Executable file
2
frappe/core/doctype/communication/email.py
Normal file → Executable file
|
|
@ -109,7 +109,7 @@ def notify(doc, print_html=None, print_format=None, attachments=None,
|
|||
else:
|
||||
check_bulk_limit(list(set(doc.sent_email_addresses)))
|
||||
from frappe.utils.background_jobs import enqueue
|
||||
enqueue(sendmail, communication_name=doc.name,
|
||||
enqueue(sendmail, queue="high", timeout=5, communication_name=doc.name,
|
||||
print_html=print_html, print_format=print_format, attachments=attachments,
|
||||
recipients=recipients, cc=cc, lang=frappe.local.lang, session=frappe.local.session)
|
||||
|
||||
|
|
|
|||
4
frappe/setup_logging.py
Normal file → Executable file
4
frappe/setup_logging.py
Normal file → Executable file
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import logging
|
||||
|
|
@ -42,6 +43,9 @@ def setup_logging():
|
|||
"propagate": False,
|
||||
"filters": ["context_filter"],
|
||||
"handlers": ["request_exception"]
|
||||
},
|
||||
"rq.worker": {
|
||||
"level": "DEBUG",
|
||||
}
|
||||
},
|
||||
"handlers": {
|
||||
|
|
|
|||
15
frappe/utils/background_jobs.py
Normal file → Executable file
15
frappe/utils/background_jobs.py
Normal file → Executable file
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
from redis import Redis
|
||||
from rq import Queue
|
||||
from rq import Connection, Queue, Worker
|
||||
import frappe
|
||||
from collections import defaultdict
|
||||
from frappe.utils import cstr
|
||||
|
|
@ -41,12 +42,8 @@ def rq_task(site, method, kwargs):
|
|||
finally:
|
||||
frappe.destroy()
|
||||
|
||||
def start_worker():
|
||||
with Connection():
|
||||
qs = ['high' , 'default', 'low']
|
||||
Worker(qs).work()
|
||||
|
||||
def new_todo(description):
|
||||
doc = frappe.get_doc({
|
||||
"doctype": "ToDo",
|
||||
"title": "My new project",
|
||||
"description": description,
|
||||
"status": "Open"
|
||||
})
|
||||
doc.insert()
|
||||
Loading…
Add table
Reference in a new issue