Slightly modify the way threaded downloads are handled

This commit is contained in:
Mathieu Comandon 2013-06-14 20:37:59 +02:00
parent 3841d62b04
commit 397e7deafb
3 changed files with 14 additions and 10 deletions

View file

@ -22,7 +22,7 @@ import optparse
import signal
# pylint: disable=E0611
from gi.repository import Gtk, GObject
from gi.repository import Gtk, Gdk, GObject
from os.path import realpath, dirname, normpath
@ -97,9 +97,11 @@ check_config(force_wipe=False)
installer = False
game = None
register_handler()
signal.signal(signal.SIGINT, signal.SIG_DFL)
GObject.threads_init()
Gdk.threads_init()
register_handler()
game_slug = []
for arg in args:

View file

@ -1,6 +1,6 @@
""" Non-blocking Gio Downloader """
import time
from gi.repository import Gio, GLib, Gtk
from gi.repository import Gio, GLib, Gtk, Gdk
class Downloader():
@ -47,14 +47,14 @@ class Downloader():
try:
mount_success = fileobj.mount_enclosing_volume_finish(result)
if mount_success:
GLib.idle_add(self.schedule_download)
Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT,
self.schedule_download, None)
except GLib.GError as ex:
if(ex.code != Gio.IOErrorEnum.ALREADY_MOUNTED and
ex.code != Gio.IOErrorEnum.NOT_SUPPORTED):
print ex.message
def schedule_download(self):
def schedule_download(self, *args):
Gio.io_scheduler_push_job(self.download, None,
GLib.PRIORITY_DEFAULT_IDLE,
Gio.Cancellable())
@ -68,4 +68,5 @@ class Downloader():
self.mount_cb,
None)
else:
GLib.idle_add(self.schedule_download)
Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT,
self.schedule_download, None)

View file

@ -2,7 +2,7 @@ import time
import urllib
import sys
import os
from gi.repository import Gtk, GObject
from gi.repository import Gtk, Gdk, GObject
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
from lutris.util import http
@ -13,9 +13,10 @@ from lutris.gui.dialogs import DownloadDialog
TEST_FILE_SIZE = 11034817
#TEST_URL = "ftp://ftp.3drealms.com/share/3dsw12.zip"
#TEST_URL = "ftp://ftp.idsoftware.com/idstuff/wolf/linux/wolf-linux-1.41b.x86.run"
#TEST_URL = "ftp://download.nvidia.com/XFree86/Linux-x86/319.23/NVIDIA-Linux-x86-319.23.run"
TEST_URL = "ftp://download.nvidia.com/XFree86/Linux-x86/319.23/NVIDIA-Linux-x86-319.23.run"
#TEST_URL = "http://strycore.com/documents/normality-en.7z"
TEST_URL = "smb://newport/games/linux/aquaria/aquaria-lnx-humble-bundle.mojo.run"
#TEST_URL = "smb://newport/games/linux/aquaria/aquaria-lnx-humble-bundle.mojo.run"
Gdk.threads_init()
GObject.threads_init()