Removed eventlet
This commit is contained in:
parent
67fcb7d37f
commit
e47a2863e8
|
@ -1,9 +1,10 @@
|
||||||
import eventlet
|
import requests
|
||||||
from eventlet.green.subprocess import call as execute
|
|
||||||
requests = eventlet.import_patched('requests')
|
|
||||||
get = requests.get
|
get = requests.get
|
||||||
request_exception = requests.exceptions
|
request_exception = requests.exceptions
|
||||||
|
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
from os.path import sep as pathSep
|
from os.path import sep as pathSep
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shlex import quote
|
from shlex import quote
|
||||||
|
@ -74,12 +75,12 @@ def downloadImage(url, path, overwrite=OverwriteOption.DONT_OVERWRITE):
|
||||||
pictureSize = int(pictureUrl[:pictureUrl.find("x")])
|
pictureSize = int(pictureUrl[:pictureUrl.find("x")])
|
||||||
if pictureSize > 1200:
|
if pictureSize > 1200:
|
||||||
logger.warn("Couldn't download "+str(pictureSize)+"x"+str(pictureSize)+" image, falling back to 1200x1200")
|
logger.warn("Couldn't download "+str(pictureSize)+"x"+str(pictureSize)+" image, falling back to 1200x1200")
|
||||||
eventlet.sleep(1)
|
sleep(1)
|
||||||
return downloadImage(urlBase+pictureUrl.replace(str(pictureSize)+"x"+str(pictureSize), '1200x1200'), path, overwrite)
|
return downloadImage(urlBase+pictureUrl.replace(str(pictureSize)+"x"+str(pictureSize), '1200x1200'), path, overwrite)
|
||||||
logger.error("Image not found: "+url)
|
logger.error("Image not found: "+url)
|
||||||
except (request_exception.ConnectionError, request_exception.ChunkedEncodingError, u3SSLError) as e:
|
except (request_exception.ConnectionError, request_exception.ChunkedEncodingError, u3SSLError) as e:
|
||||||
logger.error("Couldn't download Image, retrying in 5 seconds...: "+url+"\n")
|
logger.error("Couldn't download Image, retrying in 5 seconds...: "+url+"\n")
|
||||||
eventlet.sleep(5)
|
sleep(5)
|
||||||
return downloadImage(url, path, overwrite)
|
return downloadImage(url, path, overwrite)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno == errno.ENOSPC:
|
if e.errno == errno.ENOSPC:
|
||||||
|
@ -114,9 +115,9 @@ class DownloadJob:
|
||||||
if result: self.singleAfterDownload(result)
|
if result: self.singleAfterDownload(result)
|
||||||
elif isinstance(self.queueItem, QICollection):
|
elif isinstance(self.queueItem, QICollection):
|
||||||
tracks = [None] * len(self.queueItem.collection)
|
tracks = [None] * len(self.queueItem.collection)
|
||||||
pool = eventlet.GreenPool(size=self.settings['queueConcurrency'])
|
with ThreadPoolExecutor(self.settings['queueConcurrency']) as executor:
|
||||||
for pos, track in enumerate(self.queueItem.collection, start=0):
|
for pos, track in enumerate(self.queueItem.collection, start=0):
|
||||||
tracks[pos] = pool.spawn(self.downloadWrapper, track)
|
tracks[pos] = executor.submit(self.downloadWrapper, track)
|
||||||
pool.waitall()
|
pool.waitall()
|
||||||
self.collectionAfterDownload(tracks)
|
self.collectionAfterDownload(tracks)
|
||||||
if self.interface:
|
if self.interface:
|
||||||
|
@ -525,7 +526,7 @@ class DownloadJob:
|
||||||
except (request_exception.ConnectionError, request_exception.ChunkedEncodingError) as e:
|
except (request_exception.ConnectionError, request_exception.ChunkedEncodingError) as e:
|
||||||
if writepath.is_file(): writepath.unlink()
|
if writepath.is_file(): writepath.unlink()
|
||||||
logger.warn(f"[{track.mainArtist.name} - {track.title}] Error while downloading the track, trying again in 5s...")
|
logger.warn(f"[{track.mainArtist.name} - {track.title}] Error while downloading the track, trying again in 5s...")
|
||||||
eventlet.sleep(5)
|
sleep(5)
|
||||||
return downloadMusic(track, trackAPI_gw)
|
return downloadMusic(track, trackAPI_gw)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno == errno.ENOSPC:
|
if e.errno == errno.ENOSPC:
|
||||||
|
@ -680,7 +681,7 @@ class DownloadJob:
|
||||||
logger.info(f'{itemName} retrying from byte {chunkLength}')
|
logger.info(f'{itemName} retrying from byte {chunkLength}')
|
||||||
return self.streamTrack(stream, track, chunkLength)
|
return self.streamTrack(stream, track, chunkLength)
|
||||||
except (request_exception.ConnectionError, requests.exceptions.ReadTimeout):
|
except (request_exception.ConnectionError, requests.exceptions.ReadTimeout):
|
||||||
eventlet.sleep(2)
|
sleep(2)
|
||||||
return self.streamTrack(stream, track, start)
|
return self.streamTrack(stream, track, start)
|
||||||
|
|
||||||
def updatePercentage(self):
|
def updatePercentage(self):
|
||||||
|
|
|
@ -9,9 +9,8 @@ import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import json
|
import json
|
||||||
from os import remove
|
from os import remove
|
||||||
import eventlet
|
|
||||||
import uuid
|
import uuid
|
||||||
urlopen = eventlet.import_patched('urllib.request').urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
logger = logging.getLogger('deemix')
|
logger = logging.getLogger('deemix')
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import eventlet
|
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
eventlet.import_patched('requests.adapters')
|
import spotipy
|
||||||
|
|
||||||
spotipy = eventlet.import_patched('spotipy')
|
|
||||||
SpotifyClientCredentials = spotipy.oauth2.SpotifyClientCredentials
|
SpotifyClientCredentials = spotipy.oauth2.SpotifyClientCredentials
|
||||||
from deemix.utils.localpaths import getConfigFolder
|
from deemix.utils.localpaths import getConfigFolder
|
||||||
from deemix.app.queueitem import QIConvertable
|
from deemix.app.queueitem import QIConvertable
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import eventlet
|
from time import sleep
|
||||||
requests = eventlet.import_patched('requests')
|
import requests
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
@ -83,7 +83,7 @@ class Track:
|
||||||
)
|
)
|
||||||
result_json = site.json()
|
result_json = site.json()
|
||||||
except:
|
except:
|
||||||
eventlet.sleep(2)
|
sleep(2)
|
||||||
return self.retriveFilesizes(dz)
|
return self.retriveFilesizes(dz)
|
||||||
if len(result_json['error']):
|
if len(result_json['error']):
|
||||||
raise APIError(json.dumps(result_json['error']))
|
raise APIError(json.dumps(result_json['error']))
|
||||||
|
|
|
@ -3,5 +3,4 @@ pycryptodomex
|
||||||
mutagen
|
mutagen
|
||||||
requests
|
requests
|
||||||
spotipy>=2.11.0
|
spotipy>=2.11.0
|
||||||
eventlet
|
|
||||||
deezer-py
|
deezer-py
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -24,7 +24,7 @@ setup(
|
||||||
python_requires='>=3.6',
|
python_requires='>=3.6',
|
||||||
packages=find_packages(exclude=("tests",)),
|
packages=find_packages(exclude=("tests",)),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=["click", "pycryptodomex", "mutagen", "requests", "spotipy>=2.11.0", "eventlet", "deezer-py"],
|
install_requires=["click", "pycryptodomex", "mutagen", "requests", "spotipy>=2.11.0", "deezer-py"],
|
||||||
entry_points={
|
entry_points={
|
||||||
"console_scripts": [
|
"console_scripts": [
|
||||||
"deemix=deemix.__main__:download",
|
"deemix=deemix.__main__:download",
|
||||||
|
|
Loading…
Reference in New Issue