This commit is contained in:
ArabCoders 2024-03-31 03:49:57 +03:00
parent ae12a75ce9
commit 476d369bd1
3 changed files with 33 additions and 4 deletions

View file

@ -14,6 +14,7 @@ python-dotenv = ">=1.0.1"
python-magic = ">=0.4.27"
debugpy = ">=1.8.1"
httpx = "*"
async-timeout = "*"
[dev-packages]

27
Pipfile.lock generated
View file

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "b8c580658ddc19c696fab69a5317e66edf477f5560957ab549357b25b1b70212"
"sha256": "dc6e4544c55ad5440a21d9bedd84e11bdcd375c8a3c1ddf7708e8f99e2f7167f"
},
"pipfile-spec": 6,
"requires": {
@ -130,6 +130,15 @@
],
"version": "==1.4.0"
},
"async-timeout": {
"hashes": [
"sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f",
"sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028"
],
"index": "pypi",
"markers": "python_version >= '3.7'",
"version": "==4.0.3"
},
"attrs": {
"hashes": [
"sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30",
@ -392,6 +401,14 @@
"markers": "python_version >= '3.8'",
"version": "==1.8.1"
},
"exceptiongroup": {
"hashes": [
"sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14",
"sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"
],
"markers": "python_version < '3.11'",
"version": "==1.2.0"
},
"frozenlist": {
"hashes": [
"sha256:04ced3e6a46b4cfffe20f9ae482818e34eba9b5fb0ce4056e4cc9b6e212d09b7",
@ -740,6 +757,14 @@
"markers": "python_version >= '3.7'",
"version": "==1.3.1"
},
"typing-extensions": {
"hashes": [
"sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475",
"sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"
],
"markers": "python_version < '3.11'",
"version": "==4.10.0"
},
"tzlocal": {
"hashes": [
"sha256:49816ef2fe65ea8ac19d19aa7a1ae0551c834303d5014c6d5a62e4cbda8047b8",

View file

@ -226,8 +226,7 @@ class Download:
LOG.info(f"Closing download process: '{procId}'.")
try:
if 'update_task' in self.__dict__ and self.update_task.done() is False:
self.status_queue.put(Terminator(), timeout=3)
LOG.debug(f"Closed status queue: '{procId}'.")
self.update_task.cancel()
except Exception as e:
LOG.error(f"Failed to close status queue: '{procId}'. {e}")
pass
@ -307,7 +306,11 @@ class Download:
Update status of download task and notify the client.
"""
while True:
self.update_task = asyncio.get_running_loop().run_in_executor(None, self.status_queue.get)
try:
self.update_task = asyncio.get_running_loop().run_in_executor(None, self.status_queue.get)
except asyncio.CancelledError:
LOG.debug(f'Closing progress update for: {self.info._id=}.')
return
status = await self.update_task