mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -07:00
Limit number of failed session write attempts for activity pinger
* Default is 5 attempts, configurable manually in the config file.
This commit is contained in:
parent
baed101ef1
commit
b47f542df7
3 changed files with 29 additions and 3 deletions
|
@ -412,7 +412,7 @@ def dbcheck():
|
||||||
'audio_channels INTEGER, transcode_protocol TEXT, transcode_container TEXT, '
|
'audio_channels INTEGER, transcode_protocol TEXT, transcode_container TEXT, '
|
||||||
'transcode_video_codec TEXT, transcode_audio_codec TEXT, transcode_audio_channels INTEGER,'
|
'transcode_video_codec TEXT, transcode_audio_codec TEXT, transcode_audio_channels INTEGER,'
|
||||||
'transcode_width INTEGER, transcode_height INTEGER, buffer_count INTEGER DEFAULT 0, '
|
'transcode_width INTEGER, transcode_height INTEGER, buffer_count INTEGER DEFAULT 0, '
|
||||||
'buffer_last_triggered INTEGER, last_paused INTEGER)'
|
'buffer_last_triggered INTEGER, last_paused INTEGER, write_attempts INTEGER DEFAULT 0)'
|
||||||
)
|
)
|
||||||
|
|
||||||
# session_history table :: This is a history table which logs essential stream details
|
# session_history table :: This is a history table which logs essential stream details
|
||||||
|
@ -653,6 +653,15 @@ def dbcheck():
|
||||||
'ALTER TABLE sessions ADD COLUMN transcode_key TEXT'
|
'ALTER TABLE sessions ADD COLUMN transcode_key TEXT'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Upgrade sessions table from earlier versions
|
||||||
|
try:
|
||||||
|
c_db.execute('SELECT write_attempts FROM sessions')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
logger.debug(u"Altering database. Updating database table sessions.")
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE sessions ADD COLUMN write_attempts INTEGER DEFAULT 0'
|
||||||
|
)
|
||||||
|
|
||||||
# Upgrade session_history table from earlier versions
|
# Upgrade session_history table from earlier versions
|
||||||
try:
|
try:
|
||||||
c_db.execute('SELECT reference_id FROM session_history')
|
c_db.execute('SELECT reference_id FROM session_history')
|
||||||
|
|
|
@ -206,8 +206,24 @@ def check_active_sessions(ws_request=False):
|
||||||
monitor_db.action('DELETE FROM sessions WHERE session_key = ? AND rating_key = ?',
|
monitor_db.action('DELETE FROM sessions WHERE session_key = ? AND rating_key = ?',
|
||||||
[stream['session_key'], stream['rating_key']])
|
[stream['session_key'], stream['rating_key']])
|
||||||
else:
|
else:
|
||||||
logger.warn(u"PlexPy Monitor :: Failed to write sessionKey %s ratingKey %s to the database. " \
|
stream['write_attempts'] += 1
|
||||||
"Will try again on the next pass." % (stream['session_key'], stream['rating_key']))
|
|
||||||
|
if stream['write_attempts'] < plexpy.CONFIG.SESSION_DB_WRITE_ATTEMPTS:
|
||||||
|
logger.warn(u"PlexPy Monitor :: Failed to write sessionKey %s ratingKey %s to the database. " \
|
||||||
|
"Will try again on the next pass. Write attempt %s."
|
||||||
|
% (stream['session_key'], stream['rating_key'], str(stream['write_attempts'])))
|
||||||
|
monitor_db.action('UPDATE sessions SET write_attempts = ? '
|
||||||
|
'WHERE session_key = ? AND rating_key = ?',
|
||||||
|
[stream['write_attempts'], stream['session_key'], stream['rating_key']])
|
||||||
|
else:
|
||||||
|
logger.warn(u"PlexPy Monitor :: Failed to write sessionKey %s ratingKey %s to the database. " \
|
||||||
|
"Removing session from the database. Write attempt %s."
|
||||||
|
% (stream['session_key'], stream['rating_key'], str(stream['write_attempts'])))
|
||||||
|
logger.debug(u"PlexPy Monitor :: Removing sessionKey %s ratingKey %s from session queue"
|
||||||
|
% (stream['session_key'], stream['rating_key']))
|
||||||
|
monitor_db.action('DELETE FROM sessions WHERE session_key = ? AND rating_key = ?',
|
||||||
|
[stream['session_key'], stream['rating_key']])
|
||||||
|
|
||||||
|
|
||||||
# Process the newly received session data
|
# Process the newly received session data
|
||||||
for session in media_container:
|
for session in media_container:
|
||||||
|
|
|
@ -374,6 +374,7 @@ _CONFIG_DEFINITIONS = {
|
||||||
'REFRESH_LIBRARIES_ON_STARTUP': (int, 'Monitoring', 1),
|
'REFRESH_LIBRARIES_ON_STARTUP': (int, 'Monitoring', 1),
|
||||||
'REFRESH_USERS_INTERVAL': (int, 'Monitoring', 12),
|
'REFRESH_USERS_INTERVAL': (int, 'Monitoring', 12),
|
||||||
'REFRESH_USERS_ON_STARTUP': (int, 'Monitoring', 1),
|
'REFRESH_USERS_ON_STARTUP': (int, 'Monitoring', 1),
|
||||||
|
'SESSION_DB_WRITE_ATTEMPTS': (int, 'Monitoring', 5),
|
||||||
'SLACK_ENABLED': (int, 'Slack', 0),
|
'SLACK_ENABLED': (int, 'Slack', 0),
|
||||||
'SLACK_HOOK': (str, 'Slack', ''),
|
'SLACK_HOOK': (str, 'Slack', ''),
|
||||||
'SLACK_CHANNEL': (str, 'Slack', ''),
|
'SLACK_CHANNEL': (str, 'Slack', ''),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue