Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com> # # 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. # See LICENSE for more details. #
The AlertManager handles all the libtorrent alerts.
This should typically only be used by the Core. Plugins should utilize the `:mod:EventManager` for similar functionality.
"""
"""AlertManager fetches and processes libtorrent alerts"""
# Increase the alert queue size so that alerts don't get lost.
lt.alert.category_t.error_notification | lt.alert.category_t.port_mapping_notification | lt.alert.category_t.storage_notification | lt.alert.category_t.tracker_notification | lt.alert.category_t.status_notification | lt.alert.category_t.ip_block_notification | lt.alert.category_t.performance_warning)
# handlers is a dictionary of lists {"alert_type": [handler1,h2,..]}
""" Registers a function that will be called when 'alert_type' is pop'd in handle_alerts. The handler function should look like: handler(alert) Where 'alert' is the actual alert object from libtorrent.
:param alert_type: str, this is string representation of the alert name :param handler: func(alert), the function to be called when the alert is raised """ # There is no entry for this alert type yet, so lets make it with an # empty list.
# Append the handler to the list in the handlers dictionary
""" De-registers the `:param:handler` function from all alert types.
:param handler: func, the handler function to deregister """ # Iterate through all handlers and remove 'handler' where found # Handler is in this alert type list
"""Pops all libtorrent alerts in the session queue and handles them appropriately.
Args: wait (bool): If True the handler functions will be run straight away and waited to return before processing the next alert. """
log.debug("Alerts queued: %s", num_alerts) log.warning("Warning total alerts queued, %s, passes 90%% of queue size.", num_alerts)
# Loop through all alerts in the queue # Display the alert message log.debug("%s: %s", alert_type, decode_string(alert.message())) # Call any handlers for this alert type else: handler(alert)
"""Sets the maximum size of the libtorrent alert queue""" |