def scheduler_task(site, event, handler, now=False):
 frappe.logger(__name__).info(u'running {handler} for {site} for event: {event}'.format(handler=handler, site=site, event=event))
 try:
  if (not now):
   frappe.connect(site=site)
  frappe.flags.in_scheduler = True
  frappe.get_attr(handler)()
 except Exception:
  frappe.db.rollback()
  traceback = log(handler, u'Method: {event}, Handler: {handler}'.format(event=event, handler=handler))
  frappe.logger(__name__).error(traceback)
  raise
 else:
  frappe.db.commit()
 frappe.logger(__name__).info(u'ran {handler} for {site} for event: {event}'.format(handler=handler, site=site, event=event))

def scheduler_task ( site , event , handler , now = False ) : frappe . logger ( __name__ ) . info ( u'running {handler} for {site} for event: {event}' . format ( handler = handler , site = site , event = event ) ) try : if ( not now ) : frappe . connect ( site = site ) frappe . flags . in_scheduler = True frappe . get_attr ( handler ) ( ) except Exception : frappe . db . rollback ( ) traceback = log ( handler , u'Method: {event}, Handler: {handler}' . format ( event = event , handler = handler ) ) frappe . logger ( __name__ ) . error ( traceback ) raise else : frappe . db . commit ( ) frappe . logger ( __name__ ) . info ( u'ran {handler} for {site} for event: {event}' . format ( handler = handler , site = site , event = event ) )
this is a wrapper function that runs a hooks .