Scheduler Error

Hi Everyone,

I wrote a code which will send an email to some specific users when it is called.
After that I scheduled the code in the Scheduler for running it Weekly.

Actually what happened initially in the hooks.py
I wrote:

scheduler_events = {
	"weekly": ['library_management.update_items.autoemail_crm_updaets']
}

whereas instead of library_management it should be library as shown below:

scheduler_events = {
	"weekly": ['library.update_items.autoemail_crm_updaets']
}

And after few minutes of putting the code in Hooks.py I changed it to library instead of library management 2 days back.

Now, today I came to know that it is still giving the same error which I have resolved on the same day and did bench restart at the same time.

Method: weekly, Handler: library_management.update_items.autoemail_crm_updaets
Traceback (innermost last):
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/tasks.py", line 114, in scheduler_task
    frappe.get_attr(handler)()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/__init__.py", line 785, in get_attr
    throw(_("App {0} is not installed").format(app_name), AppNotInstalledError)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/__init__.py", line 264, in throw
    msgprint(msg, raise_exception=exc)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/__init__.py", line 257, in msgprint
    _raise_exception()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/__init__.py", line 242, in _raise_exception
    raise raise_exception, encode(msg)
 AppNotInstalledError: App library_management is not installed

where in the hooks.py it is written library instead of library_management.
May I know what did I miss.

Can you try after removing .pyc bytecode file?

Hi @revant_one @ruchin78 ,

Can you please help me here? I am getting the same error while scheduler is executing automatically. If I execute it manually by using bench execute [path] it’s working without any error.

Thank you in advance!!

If any change done by you is not reflected then try bench migrate command.

After you change something on hooks.py file you have to migrate bench to reflect those changes.

Refer documentation for more information.

Hello @Ninad1306,

Thank you for your quick response. I did this but even after I am facing this issue. For your reference, I have cross verified below points:

  • bench scheduler is enabled
  • Migrated Server
  • hooks.py looks perfect and was working on the previous server
  • Checked apps.txt file permission and looks correct.

Note: I have created a Clustered Environment. In that, there are 2 ERP Instances and two Remote Databases with Galera Clustered. On the Primary and Secondary servers, the Frappe bench & sites are the same with the same code.

Thankyou.