diff --git a/bot/helper/listeners/jdownloader_listener.py b/bot/helper/listeners/jdownloader_listener.py index 80810a03..08c9a4c0 100644 --- a/bot/helper/listeners/jdownloader_listener.py +++ b/bot/helper/listeners/jdownloader_listener.py @@ -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) diff --git a/bot/modules/bot_settings.py b/bot/modules/bot_settings.py index 0cedde03..5eee4c94 100644 --- a/bot/modules/bot_settings.py +++ b/bot/modules/bot_settings.py @@ -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