mirror of
https://gitlab.com/RemixDev/deemix-gui-pyweb.git
synced 2025-01-15 11:05:16 +00:00
Fixed: setting arl and download folder via the GUI
Waiting for a semaphore / subprocess is blocking. Fix the semaphores by using tpool (which just runs it in a separate thread in a non-blocking way). Swap to a greened subprocess module for opening download folder.
This commit is contained in:
parent
224a97bb4b
commit
18db21b61d
|
@ -7,7 +7,7 @@ from PyQt5.QtGui import QIcon
|
|||
import json
|
||||
import webbrowser
|
||||
|
||||
from threading import Thread, Lock, Semaphore
|
||||
from threading import Thread, Semaphore
|
||||
import sys
|
||||
import os.path as path
|
||||
from os import makedirs
|
||||
|
@ -16,8 +16,6 @@ from server import run_server
|
|||
from http.client import HTTPConnection
|
||||
from deemix.utils.localpaths import getConfigFolder
|
||||
|
||||
server_lock = Lock()
|
||||
|
||||
if sys.platform == "win32":
|
||||
import ctypes
|
||||
myappid = 'RemixDev.deemix'
|
||||
|
|
26
server.py
26
server.py
|
@ -2,11 +2,12 @@
|
|||
import logging
|
||||
import signal
|
||||
import sys
|
||||
import subprocess
|
||||
from os import path
|
||||
import json
|
||||
|
||||
import eventlet
|
||||
from eventlet import tpool
|
||||
from eventlet.green import subprocess
|
||||
requests = eventlet.import_patched('requests')
|
||||
urlopen = eventlet.import_patched('urllib.request').urlopen
|
||||
|
||||
|
@ -404,26 +405,35 @@ def openDownloadsFolder():
|
|||
@socketio.on('selectDownloadFolder')
|
||||
def selectDownloadFolder():
|
||||
if gui:
|
||||
gui.selectDownloadFolder_trigger.emit()
|
||||
gui._selectDownloadFolder_semaphore.acquire()
|
||||
result = gui.downloadFolder
|
||||
# Must be done with tpool to avoid blocking the greenthread
|
||||
result = tpool.execute(doSelectDowloadFolder)
|
||||
if result:
|
||||
emit('downloadFolderSelected', result)
|
||||
else:
|
||||
print("Can't open folder selection, you're not running the gui")
|
||||
|
||||
def doSelectDowloadFolder():
|
||||
gui.selectDownloadFolder_trigger.emit()
|
||||
gui._selectDownloadFolder_semaphore.acquire()
|
||||
return gui.downloadFolder
|
||||
|
||||
@socketio.on('applogin')
|
||||
def applogin():
|
||||
if gui:
|
||||
if not session['dz'].logged_in:
|
||||
gui.appLogin_trigger.emit()
|
||||
gui._appLogin_semaphore.acquire()
|
||||
if gui.arl:
|
||||
emit('applogin_arl', gui.arl)
|
||||
# Must be done with tpool to avoid blocking the greenthread
|
||||
arl = tpool.execute(dologin)
|
||||
if arl:
|
||||
emit('applogin_arl', arl)
|
||||
else:
|
||||
emit('logged_in', {'status': 2, 'user': session['dz'].user})
|
||||
else:
|
||||
print("Can't open login page, you're not running the gui")
|
||||
|
||||
def dologin():
|
||||
gui.appLogin_trigger.emit()
|
||||
gui._appLogin_semaphore.acquire()
|
||||
return gui.arl
|
||||
|
||||
def run_server(port, host="127.0.0.1", portable=None, mainWindow=None):
|
||||
global app, gui, arl, is_deezer_available
|
||||
|
|
Loading…
Reference in a new issue