Trying to handle jdownloader timeout

Signed-off-by: anasty17 <e.anastayyar@gmail.com>
This commit is contained in:
anasty17 2024-02-09 01:02:03 +02:00
parent ab32b862d7
commit 612bc4f2cf
2 changed files with 10 additions and 9 deletions

View File

@ -33,20 +33,21 @@ async def _onDownloadComplete(gid):
async def _jd_listener():
while True:
await sleep(3)
try:
await wait_for(sync_to_async(jdownloader.update_devices), timeout=5)
except:
await sync_to_async(jdownloader.jdconnect)
continue
async with jd_lock:
if len(jd_downloads) == 0:
Intervals["jd"] = ""
break
try:
packages = await sync_to_async(
jdownloader.device.downloads.query_packages, [{"finished": True}]
packages = await wait_for(
sync_to_async(
jdownloader.device.downloads.query_packages,
[{"finished": True}],
), timeout=10
)
except:
await sync_to_async(jdownloader.reconnect) or await sync_to_async(
jdownloader.jdconnect
)
continue
finished = [
pack["uuid"] for pack in packages if pack.get("finished", False)

View File

@ -318,9 +318,9 @@ async def sync_jdownloader():
).wait()
await DbManager().update_private_file("cfg.zip")
try:
await wait_for(sync_to_async(jdownloader.update_devices), timeout=5)
await wait_for(sync_to_async(jdownloader.update_devices), timeout=10)
except:
is_connected = await sync_to_async(jdownloader.jdconnect)
is_connected = await sync_to_async(jdownloader.reconnect) or await sync_to_async(jdownloader.jdconnect)
if not is_connected:
LOGGER.error(jdownloader.error)
return