Removed eventlet

This commit is contained in:
RemixDev 2021-02-11 17:30:53 +01:00
parent 67fcb7d37f
commit e47a2863e8
No known key found for this signature in database
GPG Key ID: B33962B465BDB51C
6 changed files with 17 additions and 21 deletions

View File

@ -1,9 +1,10 @@
import eventlet
from eventlet.green.subprocess import call as execute
requests = eventlet.import_patched('requests')
import requests
get = requests.get
request_exception = requests.exceptions
from concurrent.futures import ThreadPoolExecutor
from time import sleep
from os.path import sep as pathSep
from pathlib import Path
from shlex import quote
@ -74,12 +75,12 @@ def downloadImage(url, path, overwrite=OverwriteOption.DONT_OVERWRITE):
pictureSize = int(pictureUrl[:pictureUrl.find("x")])
if pictureSize > 1200:
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)
logger.error("Image not found: "+url)
except (request_exception.ConnectionError, request_exception.ChunkedEncodingError, u3SSLError) as e:
logger.error("Couldn't download Image, retrying in 5 seconds...: "+url+"\n")
eventlet.sleep(5)
sleep(5)
return downloadImage(url, path, overwrite)
except OSError as e:
if e.errno == errno.ENOSPC:
@ -114,9 +115,9 @@ class DownloadJob:
if result: self.singleAfterDownload(result)
elif isinstance(self.queueItem, QICollection):
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):
tracks[pos] = pool.spawn(self.downloadWrapper, track)
tracks[pos] = executor.submit(self.downloadWrapper, track)
pool.waitall()
self.collectionAfterDownload(tracks)
if self.interface:
@ -525,7 +526,7 @@ class DownloadJob:
except (request_exception.ConnectionError, request_exception.ChunkedEncodingError) as e:
if writepath.is_file(): writepath.unlink()
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)
except OSError as e:
if e.errno == errno.ENOSPC:
@ -680,7 +681,7 @@ class DownloadJob:
logger.info(f'{itemName} retrying from byte {chunkLength}')
return self.streamTrack(stream, track, chunkLength)
except (request_exception.ConnectionError, requests.exceptions.ReadTimeout):
eventlet.sleep(2)
sleep(2)
return self.streamTrack(stream, track, start)
def updatePercentage(self):

View File

@ -9,9 +9,8 @@ import logging
from pathlib import Path
import json
from os import remove
import eventlet
import uuid
urlopen = eventlet.import_patched('urllib.request').urlopen
from urllib.request import urlopen
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('deemix')

View File

@ -1,10 +1,7 @@
import eventlet
import json
from pathlib import Path
eventlet.import_patched('requests.adapters')
spotipy = eventlet.import_patched('spotipy')
import spotipy
SpotifyClientCredentials = spotipy.oauth2.SpotifyClientCredentials
from deemix.utils.localpaths import getConfigFolder
from deemix.app.queueitem import QIConvertable

View File

@ -1,5 +1,5 @@
import eventlet
requests = eventlet.import_patched('requests')
from time import sleep
import requests
import logging
logging.basicConfig(level=logging.INFO)
@ -83,7 +83,7 @@ class Track:
)
result_json = site.json()
except:
eventlet.sleep(2)
sleep(2)
return self.retriveFilesizes(dz)
if len(result_json['error']):
raise APIError(json.dumps(result_json['error']))

View File

@ -3,5 +3,4 @@ pycryptodomex
mutagen
requests
spotipy>=2.11.0
eventlet
deezer-py

View File

@ -24,7 +24,7 @@ setup(
python_requires='>=3.6',
packages=find_packages(exclude=("tests",)),
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={
"console_scripts": [
"deemix=deemix.__main__:download",