Run_every only runs once

Tags: #<Tag:0x00007f326d0bde38>

My run_every callback should run every 5 minutes. I’ve seen nothing in the log for over an hour.

AppDaemon LOG

020-10-29 21:01:43.020536 WARNING check_mailgun_activity: Unexpected error in worker for App check_mailgun_activity:
2020-10-29 21:01:43.022279 WARNING check_mailgun_activity: Worker Ags: {'id': 'dfdbda8482ca47beac4ef3a57424a708', 'name': 'check_mailgun_activity', 'objectid': '14e6d2d7fbe94a9d8beb0d4f51f57d53', 'type': 'scheduler', 'function': <bound method CheckMailgunActivity.check of <check_mailgun_activity.CheckMailgunActivity object at 0xb5863c40>>, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'interval': 300, '__thread_id': 'thread-0'}}
2020-10-29 21:01:43.023993 WARNING check_mailgun_activity: ------------------------------------------------------------
2020-10-29 21:01:43.032022 WARNING check_mailgun_activity: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 887, in worker
    funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
  File "/config/appdaemon/apps/check_mailgun_activity.py", line 30, in check
    self.call_service('homeassistant/restart')
  File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 195, in inner_sync_wrapper
    f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
  File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 299, in run_coroutine_threadsafe
    result = future.result(self.AD.internal_function_timeout)
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 441, in result
    raise TimeoutError()
concurrent.futures._base.TimeoutError
2020-10-29 21:01:43.034054 WARNING check_mailgun_activity: ------------------------------------------------------------
2020-10-29 21:01:43.041174 WARNING AppDaemon: callback check() in check_mailgun_activity has now completed
2020-10-29 21:01:43.923910 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2020-10-29 21:01:48.940280 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2020-10-29 21:01:53.950208 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2020-10-29 21:01:54.213321 INFO AppDaemon: New client Admin Client connected
2020-10-29 21:01:55.266240 INFO AppDaemon: Client disconnection from Admin Client
2020-10-29 21:01:55.380926 INFO AppDaemon: New client Admin Client connected
2020-10-29 21:01:57.073280 INFO AppDaemon: Client disconnection from Admin Client
2020-10-29 21:01:57.201340 INFO AppDaemon: New client Admin Client connected
2020-10-29 21:01:58.960793 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2020-10-29 21:02:03.979103 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2020-10-29 21:02:09.009784 INFO HASS: Connected to Home Assistant 0.106.2
2020-10-29 21:02:09.093864 INFO HASS: Evaluating startup conditions
2020-10-29 21:02:09.118750 INFO HASS: All startup conditions met
2020-10-29 21:02:09.160960 INFO AppDaemon: Processing restart for HASS
2020-10-29 21:02:09.161801 INFO AppDaemon: Terminating check_mailgun_activity
2020-10-29 21:02:09.164090 INFO AppDaemon: Initializing app check_mailgun_activity using class CheckMailgunActivity from module check_mailgun_activity
{'namespace': 'default', 'domain': 'notify', 'service': 'mailgun'}
Mailgun was found
2020-10-29 21:04:10.761155 INFO AppDaemon: Client disconnection from Admin Client

My AppDaemon App:

import os, subprocess
import appdaemon.plugins.hass.hassapi as hass

#
# Check if the activity.mailgun service failed to load. This happens when hass.io boots with no internet connection
#
# Args:
#

class CheckMailgunActivity(hass.Hass):

  def initialize(self):
    #self.notify("App started", name="mailgun")
    handle = self.run_every(self.check, 'now+60', 60*5) # 5 minutes

  def check(self, some_arg):
    mailgun_ok = False
    try:
        for s in self.list_services():
            if s.get('namespace') == 'default' and s.get('domain') == 'notify' and s.get('service') == 'mailgun':
                print(s)
                mailgun_ok = True
    except Exception as e:
        print (e)
        return

    if not mailgun_ok:
        print("Mailgun notify service not found, restarting HA")
        self.call_service('homeassistant/restart')
    else:
        print("Mailgun was found")