Commit af023f19 authored by echel0n's avatar echel0n
Browse files

Fixed `JSON serializable` issues in server API v1 for shows and shows.seasons endpoints

Added better exception handling for AMQP consumer and base
parent 64569ac5
......@@ -23,7 +23,7 @@ import ssl
import pika
from pika.adapters.tornado_connection import TornadoConnection
from pika.adapters.utils.connection_workflow import AMQPConnectorException
from pika.exceptions import StreamLostError, AMQPConnectionError
from pika.exceptions import StreamLostError, AMQPConnectionError, ChannelWrongStateError
from tornado.ioloop import IOLoop
import sickrage
......@@ -91,13 +91,13 @@ class AMQPBase(object):
if self._channel and not self._channel.is_closed:
try:
self._channel.close()
except StreamLostError:
except (ChannelWrongStateError, StreamLostError):
pass
if self._connection and not self._connection.is_closed:
try:
self._connection.close()
except StreamLostError:
except (ChannelWrongStateError, StreamLostError):
pass
self._channel = None
......@@ -118,7 +118,6 @@ class AMQPBase(object):
def reconnect(self):
if not self._closing:
self.disconnect()
self.connect()
def on_channel_open(self, channel):
......
......@@ -20,6 +20,7 @@
# ##############################################################################
from google.protobuf.json_format import MessageToDict
from pika.exceptions import ChannelWrongStateError, StreamLostError
from tornado.ioloop import IOLoop
import sickrage
......@@ -102,6 +103,6 @@ class AMQPConsumer(AMQPBase):
on_message_callback=self.on_message,
queue=f'{sickrage.app.config.user.sub_id}.{sickrage.app.config.general.server_id}',
)
except Exception as e:
sickrage.app.log.debug(f'Exception happened during consuming AMQP messages: {e!r}')
IOLoop.current().call_later(5, self.reconnect)
except (ChannelWrongStateError, StreamLostError):
sickrage.app.log.debug('AMQP channel error, attempting to reconnect')
IOLoop.current().call_later(5, self.reconnect)
\ No newline at end of file
......@@ -38,7 +38,7 @@ from sickrage.core.caches import image_cache
from sickrage.core.common import dateFormat, dateTimeFormat, Overview, timeFormat, Quality, Qualities, EpisodeStatus
from sickrage.core.databases.main import MainDB
from sickrage.core.databases.main.schemas import TVEpisodeSchema
from sickrage.core.enums import ProcessMethod, SeriesProviderID
from sickrage.core.enums import ProcessMethod, SeriesProviderID, SearchFormat
from sickrage.core.exceptions import EpisodeNotFoundException, CantRemoveShowException, CantRefreshShowException, CantUpdateShowException
from sickrage.core.helpers import backup_app_data, srdatetime, pretty_file_size, read_file_buffered, try_int, sanitize_file_name, chmod_as_parent, flatten, \
make_dir
......@@ -1731,7 +1731,7 @@ class CMD_Show(ApiV1Handler):
showDict["show_name"] = show_object.name
showDict["paused"] = (0, 1)[show_object.paused]
showDict["subtitles"] = (0, 1)[show_object.subtitles]
showDict["search_format"] = show_object.search_format
showDict["search_format"] = SearchFormat(show_object.search_format).display_name
showDict["flatten_folders"] = (0, 1)[show_object.flatten_folders]
showDict["scene"] = (0, 1)[show_object.scene]
showDict["anime"] = (0, 1)[show_object.anime]
......@@ -2354,6 +2354,8 @@ class CMD_ShowSeasons(ApiV1Handler):
for row in db_data:
episode_dict = row.as_dict()
episode_dict['series_provider_id'] = SeriesProviderID(episode_dict['series_provider_id']).display_name
status, quality = Quality.split_composite_status(int(episode_dict['status']))
episode_dict['status'] = status.display_name
episode_dict['quality'] = quality.display_name
......@@ -2596,7 +2598,7 @@ class CMD_Shows(ApiV1Handler):
"paused": (0, 1)[curShow.paused],
"quality": Qualities(curShow.quality).display_name,
"language": curShow.lang,
"search_format": curShow.search_format,
"search_format": SearchFormat(curShow.search_format).display_name,
"anime": (0, 1)[curShow.anime],
"series_id": curShow.series_id,
"series_provider_id": curShow.series_provider.name,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment