<commit_before>from __future__ import unicode_literals
from frappe.celery_app import app
import frappe
from frappe.cli import get_sites
from frappe.utils.file_lock import delete_lock

from celery.utils.log import get_task_logger

logger = get_task_logger(__name__)

@app.task()
def sync_queues():
	sites = get_sites()
	for site in sites:
		app.control.broadcast('add_consumer', arguments={'queue': site}, reply=True)

@app.task()
def scheduler_task(site, event, handler):
	from frappe.utils.scheduler import log
	traceback = ""
	try:
		frappe.init(site=site)
		frappe.connect()
		frappe.get_attr(handler)()
		frappe.conn.commit()
		delete_lock(handler)
	except Exception:
		traceback += log("Method: {event}, Handler: {handler}".format(event=event, handler=handler))
		traceback += log(frappe.get_traceback())
		logger.warn(traceback)
		frappe.conn.rollback()
	frappe.destroy()
	logger.info('ran {handler} for {site} for event: {event}'.format(handler=handler, site=site, event=event))

@app.task()
def enqueue_scheduler_events():
	import frappe
	from frappe.utils.scheduler import execute
	logger.info('ran {handler} for {site} for event: {event}')<commit_msg>destroy and raise after every scheduler task<commit_after>from __future__ import unicode_literals
from frappe.celery_app import app
import frappe
from frappe.cli import get_sites
from frappe.utils.file_lock import delete_lock

from celery.utils.log import get_task_logger

logger = get_task_logger(__name__)

@app.task()
def sync_queues():
	sites = get_sites()
	for site in sites:
		app.control.broadcast('add_consumer', arguments={'queue': site}, reply=True)

@app.task()
def scheduler_task(site, event, handler):
	from frappe.utils.scheduler import log
	traceback = ""
	try:
		frappe.init(site=site)
		frappe.connect()
		frappe.get_attr(handler)()
		frappe.conn.commit()
		delete_lock(handler)
	except Exception:
		traceback += log("Method: {event}, Handler: {handler}".format(event=event, handler=handler))
		traceback += log(frappe.get_traceback())
		logger.warn(traceback)
		frappe.conn.rollback()
		frappe.destroy()
		raise
	frappe.destroy()
	logger.info('ran {handler} for {site} for event: {event}'.format(handler=handler, site=site, event=event))

@app.task()
def enqueue_scheduler_events():
	import frappe
	from frappe.utils.scheduler import execute
	logger.info('ran {handler} for {site} for event: {event}')
{'fraction_non_alphanumeric': 0.1264705882352941, 'fraction_numerical': 0.0, 'mean_word_length': 6.086309523809524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6837582', 'n_tokens_mistral': 828, 'n_tokens_neox': 822, 'n_words': 189}