mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-03 07:03:39 +00:00
[Core] Convert inlineCallbacks to maybe_coroutine
Make logging functions synchronous. They were not calling any async functions, and wrapping them in maybe_coroutine caused reactor to be imported before gtkui could install the gtk reactor. Closes: https://github.com/deluge-torrent/deluge/pull/353
This commit is contained in:
parent
b76f2c0f20
commit
2fb41341c9
@ -38,7 +38,7 @@ from deluge.core.pluginmanager import PluginManager
|
|||||||
from deluge.core.preferencesmanager import PreferencesManager
|
from deluge.core.preferencesmanager import PreferencesManager
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
from deluge.core.torrentmanager import TorrentManager
|
from deluge.core.torrentmanager import TorrentManager
|
||||||
from deluge.decorators import deprecated
|
from deluge.decorators import deprecated, maybe_coroutine
|
||||||
from deluge.error import (
|
from deluge.error import (
|
||||||
AddTorrentError,
|
AddTorrentError,
|
||||||
DelugeError,
|
DelugeError,
|
||||||
@ -498,13 +498,13 @@ class Core(component.Component):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@maybe_coroutine
|
||||||
def add_torrents():
|
async def add_torrents():
|
||||||
errors = []
|
errors = []
|
||||||
last_index = len(torrent_files) - 1
|
last_index = len(torrent_files) - 1
|
||||||
for idx, torrent in enumerate(torrent_files):
|
for idx, torrent in enumerate(torrent_files):
|
||||||
try:
|
try:
|
||||||
yield self.add_torrent_file_async(
|
await self.add_torrent_file_async(
|
||||||
torrent[0], torrent[1], torrent[2], save_state=idx == last_index
|
torrent[0], torrent[1], torrent[2], save_state=idx == last_index
|
||||||
)
|
)
|
||||||
except AddTorrentError as ex:
|
except AddTorrentError as ex:
|
||||||
@ -769,14 +769,14 @@ class Core(component.Component):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@export
|
@export
|
||||||
@defer.inlineCallbacks
|
@maybe_coroutine
|
||||||
def get_torrents_status(self, filter_dict, keys, diff=False):
|
async def get_torrents_status(self, filter_dict, keys, diff=False):
|
||||||
"""
|
"""
|
||||||
returns all torrents , optionally filtered by filter_dict.
|
returns all torrents , optionally filtered by filter_dict.
|
||||||
"""
|
"""
|
||||||
all_keys = not keys
|
all_keys = not keys
|
||||||
torrent_ids = self.filtermanager.filter_torrent_ids(filter_dict)
|
torrent_ids = self.filtermanager.filter_torrent_ids(filter_dict)
|
||||||
status_dict, plugin_keys = yield self.torrentmanager.torrents_status_update(
|
status_dict, plugin_keys = await self.torrentmanager.torrents_status_update(
|
||||||
torrent_ids, keys, diff=diff
|
torrent_ids, keys, diff=diff
|
||||||
)
|
)
|
||||||
# Ask the plugin manager to fill in the plugin keys
|
# Ask the plugin manager to fill in the plugin keys
|
||||||
|
@ -33,6 +33,7 @@ from deluge.common import (
|
|||||||
from deluge.configmanager import ConfigManager, get_config_dir
|
from deluge.configmanager import ConfigManager, get_config_dir
|
||||||
from deluge.core.authmanager import AUTH_LEVEL_ADMIN
|
from deluge.core.authmanager import AUTH_LEVEL_ADMIN
|
||||||
from deluge.core.torrent import Torrent, TorrentOptions, sanitize_filepath
|
from deluge.core.torrent import Torrent, TorrentOptions, sanitize_filepath
|
||||||
|
from deluge.decorators import maybe_coroutine
|
||||||
from deluge.error import AddTorrentError, InvalidTorrentError
|
from deluge.error import AddTorrentError, InvalidTorrentError
|
||||||
from deluge.event import (
|
from deluge.event import (
|
||||||
ExternalIPEvent,
|
ExternalIPEvent,
|
||||||
@ -247,8 +248,8 @@ class TorrentManager(component.Component):
|
|||||||
self.save_resume_data_timer.start(190, False)
|
self.save_resume_data_timer.start(190, False)
|
||||||
self.prev_status_cleanup_loop.start(10)
|
self.prev_status_cleanup_loop.start(10)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@maybe_coroutine
|
||||||
def stop(self):
|
async def stop(self):
|
||||||
# Stop timers
|
# Stop timers
|
||||||
if self.save_state_timer.running:
|
if self.save_state_timer.running:
|
||||||
self.save_state_timer.stop()
|
self.save_state_timer.stop()
|
||||||
@ -260,11 +261,11 @@ class TorrentManager(component.Component):
|
|||||||
self.prev_status_cleanup_loop.stop()
|
self.prev_status_cleanup_loop.stop()
|
||||||
|
|
||||||
# Save state on shutdown
|
# Save state on shutdown
|
||||||
yield self.save_state()
|
await self.save_state()
|
||||||
|
|
||||||
self.session.pause()
|
self.session.pause()
|
||||||
|
|
||||||
result = yield self.save_resume_data(flush_disk_cache=True)
|
result = await self.save_resume_data(flush_disk_cache=True)
|
||||||
# Remove the temp_file to signify successfully saved state
|
# Remove the temp_file to signify successfully saved state
|
||||||
if result and os.path.isfile(self.temp_file):
|
if result and os.path.isfile(self.temp_file):
|
||||||
os.remove(self.temp_file)
|
os.remove(self.temp_file)
|
||||||
|
@ -51,39 +51,31 @@ class Logging(LoggingLoggerClass):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def garbage(self, msg, *args, **kwargs):
|
def garbage(self, msg, *args, **kwargs):
|
||||||
yield LoggingLoggerClass.log(self, 1, msg, *args, **kwargs)
|
LoggingLoggerClass.log(self, 1, msg, *args, **kwargs)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def trace(self, msg, *args, **kwargs):
|
def trace(self, msg, *args, **kwargs):
|
||||||
yield LoggingLoggerClass.log(self, 5, msg, *args, **kwargs)
|
LoggingLoggerClass.log(self, 5, msg, *args, **kwargs)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def debug(self, msg, *args, **kwargs):
|
def debug(self, msg, *args, **kwargs):
|
||||||
yield LoggingLoggerClass.debug(self, msg, *args, **kwargs)
|
LoggingLoggerClass.debug(self, msg, *args, **kwargs)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def info(self, msg, *args, **kwargs):
|
def info(self, msg, *args, **kwargs):
|
||||||
yield LoggingLoggerClass.info(self, msg, *args, **kwargs)
|
LoggingLoggerClass.info(self, msg, *args, **kwargs)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def warning(self, msg, *args, **kwargs):
|
def warning(self, msg, *args, **kwargs):
|
||||||
yield LoggingLoggerClass.warning(self, msg, *args, **kwargs)
|
LoggingLoggerClass.warning(self, msg, *args, **kwargs)
|
||||||
|
|
||||||
warn = warning
|
warn = warning
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def error(self, msg, *args, **kwargs):
|
def error(self, msg, *args, **kwargs):
|
||||||
yield LoggingLoggerClass.error(self, msg, *args, **kwargs)
|
LoggingLoggerClass.error(self, msg, *args, **kwargs)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def critical(self, msg, *args, **kwargs):
|
def critical(self, msg, *args, **kwargs):
|
||||||
yield LoggingLoggerClass.critical(self, msg, *args, **kwargs)
|
LoggingLoggerClass.critical(self, msg, *args, **kwargs)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def exception(self, msg, *args, **kwargs):
|
def exception(self, msg, *args, **kwargs):
|
||||||
yield LoggingLoggerClass.exception(self, msg, *args, **kwargs)
|
LoggingLoggerClass.exception(self, msg, *args, **kwargs)
|
||||||
|
|
||||||
def findCaller(self, *args, **kwargs): # NOQA: N802
|
def findCaller(self, *args, **kwargs): # NOQA: N802
|
||||||
f = logging.currentframe().f_back
|
f = logging.currentframe().f_back
|
||||||
|
Loading…
x
Reference in New Issue
Block a user