Improved how Bazarr deals with Sonarr SignalR feed issues that are raising exceptions.

pull/1485/head v0.9.7-beta.1
morpheus65535 3 years ago
parent 117da38fe6
commit 5e3ce8c8c3

@ -204,10 +204,12 @@ def proxy(protocol, url):
return dict(status=False, error=result.raise_for_status()) return dict(status=False, error=result.raise_for_status())
greenlets = []
if settings.general.getboolean('use_sonarr'): if settings.general.getboolean('use_sonarr'):
Greenlet.spawn(sonarr_signalr_client.start) greenlets.append(Greenlet.spawn(sonarr_signalr_client.start))
if settings.general.getboolean('use_radarr'): if settings.general.getboolean('use_radarr'):
Greenlet.spawn(radarr_signalr_client.start) greenlets.append(Greenlet.spawn(radarr_signalr_client.start))
gevent.joinall(greenlets)
if __name__ == "__main__": if __name__ == "__main__":

@ -33,26 +33,30 @@ class SonarrSignalrClient:
self.connection = None self.connection = None
def start(self): def start(self):
if get_sonarr_version().startswith('2.'): sonarr_version = get_sonarr_version()
if sonarr_version.startswith('2.'):
logging.warning('BAZARR can only sync from Sonarr v3 SignalR feed to get real-time update. You should ' logging.warning('BAZARR can only sync from Sonarr v3 SignalR feed to get real-time update. You should '
'consider upgrading.') 'consider upgrading your version({}).'.format(sonarr_version))
return raise gevent.GreenletExit
else:
logging.info('BAZARR trying to connect to Sonarr SignalR feed...') logging.info('BAZARR trying to connect to Sonarr SignalR feed...')
self.configure() self.configure()
while not self.connection.started: while not self.connection.started:
try: try:
self.connection.start() self.connection.start()
except ConnectionError: except ConnectionError:
gevent.sleep(5) gevent.sleep(5)
except json.decoder.JSONDecodeError: except json.decoder.JSONDecodeError:
logging.error("BAZARR cannot parse JSON returned by SignalR feed. This is a known issue when Sonarr " logging.error("BAZARR cannot parse JSON returned by SignalR feed. This is a known issue when "
"doesn't have write permission to it's /config/xdg directory.") "Sonarr have issue accessing it's /config/xdg directory. You should delete that "
self.stop() "directory and restart Sonarr.")
logging.info('BAZARR SignalR client for Sonarr is connected and waiting for events.') raise gevent.GreenletExit
if not args.dev: else:
scheduler.add_job(update_series, kwargs={'send_event': True}, max_instances=1) logging.info('BAZARR SignalR client for Sonarr is connected and waiting for events.')
scheduler.add_job(sync_episodes, kwargs={'send_event': True}, max_instances=1) finally:
if not args.dev:
scheduler.add_job(update_series, kwargs={'send_event': True}, max_instances=1)
scheduler.add_job(sync_episodes, kwargs={'send_event': True}, max_instances=1)
def stop(self, log=True): def stop(self, log=True):
try: try:

Loading…
Cancel
Save