diff --git a/frappe/__init__.py b/frappe/__init__.py index 2f80353147..da8a8ef65c 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json from .exceptions import * from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template -__version__ = '9.0.9' +__version__ = '9.0.10' __title__ = "Frappe Framework" local = Local() diff --git a/frappe/email/doctype/email_account/email_account.py b/frappe/email/doctype/email_account/email_account.py index 7dbb71fd3f..53cb6b8dd7 100755 --- a/frappe/email/doctype/email_account/email_account.py +++ b/frappe/email/doctype/email_account/email_account.py @@ -684,36 +684,27 @@ def pull(now=False): frappe.cache().set_value("workers:no-internet", False) else: return - queued_jobs = get_jobs(site=frappe.local.site, key='job_name')[frappe.local.site] - email_accounts = frappe.db.sql_list("""select name from `tabEmail Account` where - enable_incoming=1 and awaiting_password=0""") - - # No incoming email account available - if not email_accounts: - return + for email_account in frappe.get_list("Email Account", + filters={"enable_incoming": 1, "awaiting_password": 0}): + if now: + pull_from_email_account(email_account.name) - if now: - pull_from_email_accounts(email_accounts) - else: - # job_name is used to prevent duplicates in queue - job_name = 'pull_from_email_accounts|{0}'.format(",".join(email_accounts)) + else: + # job_name is used to prevent duplicates in queue + job_name = 'pull_from_email_account|{0}'.format(email_account.name) - if job_name not in queued_jobs: - enqueue(pull_from_email_accounts, 'short', event='all', job_name=job_name, - email_accounts=email_accounts) + if job_name not in queued_jobs: + enqueue(pull_from_email_account, 'short', event='all', job_name=job_name, + email_account=email_account.name) -def pull_from_email_accounts(email_accounts): +def pull_from_email_account(email_account): '''Runs within a worker process''' - if not email_accounts: - return - - for email_account in email_accounts: - email_account = frappe.get_doc("Email Account", email_account) - email_account.receive() + email_account = frappe.get_doc("Email Account", email_account) + email_account.receive() - # mark Email Flag Queue mail as read - email_account.mark_emails_as_read_unread() + # mark Email Flag Queue mail as read + email_account.mark_emails_as_read_unread() def get_max_email_uid(email_account): # get maximum uid of emails