mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-12 12:34:43 +00:00
Set alert_queue_size in AlertManager and add logging
This commit is contained in:
parent
ccec01b729
commit
02592e1b5e
@ -1,42 +1,17 @@
|
|||||||
#
|
# -*- coding: utf-8 -*-
|
||||||
# alertmanager.py
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
|
||||||
#
|
# the additional special exception to link portions of this program with the OpenSSL library.
|
||||||
# You may redistribute it and/or modify it under the terms of the
|
# See LICENSE for more details.
|
||||||
# GNU General Public License, as published by the Free Software
|
|
||||||
# Foundation; either version 3 of the License, or (at your option)
|
|
||||||
# any later version.
|
|
||||||
#
|
|
||||||
# deluge is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
# See the GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with deluge. If not, write to:
|
|
||||||
# The Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor
|
|
||||||
# Boston, MA 02110-1301, USA.
|
|
||||||
#
|
|
||||||
# In addition, as a special exception, the copyright holders give
|
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
|
||||||
# library.
|
|
||||||
# You must obey the GNU General Public License in all respects for all of
|
|
||||||
# the code used other than OpenSSL. If you modify file(s) with this
|
|
||||||
# exception, you may extend this exception to your version of the file(s),
|
|
||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
|
||||||
# this exception statement from your version. If you delete this exception
|
|
||||||
# statement from all source files in the program, then also delete it here.
|
|
||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
The AlertManager handles all the libtorrent alerts.
|
The AlertManager handles all the libtorrent alerts.
|
||||||
|
|
||||||
This should typically only be used by the Core. Plugins should utilize the
|
This should typically only be used by the Core. Plugins should utilize the
|
||||||
`:mod:EventManager` for similar functionality.
|
`:mod:EventManager` for similar functionality.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -53,10 +28,14 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class AlertManager(component.Component):
|
class AlertManager(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
log.debug("AlertManager initialized..")
|
log.debug("AlertManager init...")
|
||||||
component.Component.__init__(self, "AlertManager", interval=0.3)
|
component.Component.__init__(self, "AlertManager", interval=0.3)
|
||||||
self.session = component.get("Core").session
|
self.session = component.get("Core").session
|
||||||
|
|
||||||
|
# Increase the alert queue size so that alerts don't get lost.
|
||||||
|
self.alert_queue_size = 10000
|
||||||
|
self.set_alert_queue_size(self.alert_queue_size)
|
||||||
|
|
||||||
self.session.set_alert_mask(
|
self.session.set_alert_mask(
|
||||||
lt.alert.category_t.error_notification |
|
lt.alert.category_t.error_notification |
|
||||||
lt.alert.category_t.port_mapping_notification |
|
lt.alert.category_t.port_mapping_notification |
|
||||||
@ -120,6 +99,15 @@ class AlertManager(component.Component):
|
|||||||
away and waited to return before processing the next alert
|
away and waited to return before processing the next alert
|
||||||
"""
|
"""
|
||||||
alerts = self.session.pop_alerts()
|
alerts = self.session.pop_alerts()
|
||||||
|
if not alerts:
|
||||||
|
return
|
||||||
|
|
||||||
|
num_alerts = len(alerts)
|
||||||
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
|
log.debug("Alerts queued: %s", num_alerts)
|
||||||
|
if num_alerts > 0.9 * self.alert_queue_size:
|
||||||
|
log.warning("Warning total alerts queued, %s, passes 90%% of queue size.", num_alerts)
|
||||||
|
|
||||||
# Loop through all alerts in the queue
|
# Loop through all alerts in the queue
|
||||||
for alert in alerts:
|
for alert in alerts:
|
||||||
alert_type = type(alert).__name__
|
alert_type = type(alert).__name__
|
||||||
@ -133,3 +121,10 @@ class AlertManager(component.Component):
|
|||||||
self.delayed_calls.append(reactor.callLater(0, handler, alert))
|
self.delayed_calls.append(reactor.callLater(0, handler, alert))
|
||||||
else:
|
else:
|
||||||
handler(alert)
|
handler(alert)
|
||||||
|
|
||||||
|
def set_alert_queue_size(self, queue_size):
|
||||||
|
log.info("Alert Queue Size set to %s", queue_size)
|
||||||
|
self.alert_queue_size = queue_size
|
||||||
|
settings = self.session.get_settings()
|
||||||
|
settings["alert_queue_size"] = self.alert_queue_size
|
||||||
|
self.session.set_settings(settings)
|
||||||
|
@ -88,25 +88,17 @@ class Core(component.Component):
|
|||||||
# Load the session state if available
|
# Load the session state if available
|
||||||
self.__load_session_state()
|
self.__load_session_state()
|
||||||
|
|
||||||
## Set Session settings ##
|
## Set session settings ##
|
||||||
settings = self.session.get_settings()
|
settings = self.session.get_settings()
|
||||||
|
|
||||||
# User agent
|
|
||||||
settings["user_agent"] = "Deluge/%(deluge_version)s libtorrent/%(lt_version)s" % {
|
settings["user_agent"] = "Deluge/%(deluge_version)s libtorrent/%(lt_version)s" % {
|
||||||
'deluge_version': deluge.common.get_version(),
|
'deluge_version': deluge.common.get_version(),
|
||||||
'lt_version': self.get_libtorrent_version().rpartition(".")[0]
|
'lt_version': self.get_libtorrent_version().rpartition(".")[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Increase the alert queue size so that alerts don't get lost.
|
|
||||||
settings["alert_queue_size"] = 10000
|
|
||||||
|
|
||||||
# On Windows OS set the disk I/O read/write to bypass OS cache
|
# On Windows OS set the disk I/O read/write to bypass OS cache
|
||||||
if deluge.common.windows_check():
|
if deluge.common.windows_check():
|
||||||
settings["disk_io_write_mode"] = lt.io_buffer_mode_t.disable_os_cache
|
settings["disk_io_write_mode"] = lt.io_buffer_mode_t.disable_os_cache
|
||||||
settings["disk_io_read_mode"] = lt.io_buffer_mode_t.disable_os_cache
|
settings["disk_io_read_mode"] = lt.io_buffer_mode_t.disable_os_cache
|
||||||
|
|
||||||
self.session.set_settings(settings)
|
self.session.set_settings(settings)
|
||||||
## End Set Session settings ##
|
|
||||||
|
|
||||||
## libtorrent plugins ##
|
## libtorrent plugins ##
|
||||||
# Allows peers to download the metadata from the swarm directly
|
# Allows peers to download the metadata from the swarm directly
|
||||||
|
Loading…
x
Reference in New Issue
Block a user