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 json
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|
||||||
from threading import Thread, Lock, Semaphore
|
from threading import Thread, Semaphore
|
||||||
import sys
|
import sys
|
||||||
import os.path as path
|
import os.path as path
|
||||||
from os import makedirs
|
from os import makedirs
|
||||||
|
@ -16,8 +16,6 @@ from server import run_server
|
||||||
from http.client import HTTPConnection
|
from http.client import HTTPConnection
|
||||||
from deemix.utils.localpaths import getConfigFolder
|
from deemix.utils.localpaths import getConfigFolder
|
||||||
|
|
||||||
server_lock = Lock()
|
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
import ctypes
|
import ctypes
|
||||||
myappid = 'RemixDev.deemix'
|
myappid = 'RemixDev.deemix'
|
||||||
|
|
26
server.py
26
server.py
|
@ -2,11 +2,12 @@
|
||||||
import logging
|
import logging
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
|
||||||
from os import path
|
from os import path
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
|
from eventlet import tpool
|
||||||
|
from eventlet.green import subprocess
|
||||||
requests = eventlet.import_patched('requests')
|
requests = eventlet.import_patched('requests')
|
||||||
urlopen = eventlet.import_patched('urllib.request').urlopen
|
urlopen = eventlet.import_patched('urllib.request').urlopen
|
||||||
|
|
||||||
|
@ -404,27 +405,36 @@ def openDownloadsFolder():
|
||||||
@socketio.on('selectDownloadFolder')
|
@socketio.on('selectDownloadFolder')
|
||||||
def selectDownloadFolder():
|
def selectDownloadFolder():
|
||||||
if gui:
|
if gui:
|
||||||
gui.selectDownloadFolder_trigger.emit()
|
# Must be done with tpool to avoid blocking the greenthread
|
||||||
gui._selectDownloadFolder_semaphore.acquire()
|
result = tpool.execute(doSelectDowloadFolder)
|
||||||
result = gui.downloadFolder
|
|
||||||
if result:
|
if result:
|
||||||
emit('downloadFolderSelected', result)
|
emit('downloadFolderSelected', result)
|
||||||
else:
|
else:
|
||||||
print("Can't open folder selection, you're not running the gui")
|
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')
|
@socketio.on('applogin')
|
||||||
def applogin():
|
def applogin():
|
||||||
if gui:
|
if gui:
|
||||||
if not session['dz'].logged_in:
|
if not session['dz'].logged_in:
|
||||||
gui.appLogin_trigger.emit()
|
# Must be done with tpool to avoid blocking the greenthread
|
||||||
gui._appLogin_semaphore.acquire()
|
arl = tpool.execute(dologin)
|
||||||
if gui.arl:
|
if arl:
|
||||||
emit('applogin_arl', gui.arl)
|
emit('applogin_arl', arl)
|
||||||
else:
|
else:
|
||||||
emit('logged_in', {'status': 2, 'user': session['dz'].user})
|
emit('logged_in', {'status': 2, 'user': session['dz'].user})
|
||||||
else:
|
else:
|
||||||
print("Can't open login page, you're not running the gui")
|
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):
|
def run_server(port, host="127.0.0.1", portable=None, mainWindow=None):
|
||||||
global app, gui, arl, is_deezer_available
|
global app, gui, arl, is_deezer_available
|
||||||
app = deemix(portable)
|
app = deemix(portable)
|
||||||
|
|
Loading…
Reference in a new issue