Retries
This commit is contained in:
parent
54876a052d
commit
f3dc9bb001
3 changed files with 78 additions and 59 deletions
|
|
@ -17,12 +17,12 @@ export default async (req: Request, res: Response) => {
|
||||||
|
|
||||||
// Determine how many items in the queue are ahead of this one
|
// Determine how many items in the queue are ahead of this one
|
||||||
const aheadInQueue = await Jobs.find({
|
const aheadInQueue = await Jobs.find({
|
||||||
queue_place: { $lt: job.queuePlace },
|
queue_place: { $lte: job.queuePlace },
|
||||||
});
|
});
|
||||||
|
|
||||||
let text: string = "";
|
let text: string = "";
|
||||||
if (job.status == Status.ENQUEUED) {
|
if (job.status == Status.ENQUEUED) {
|
||||||
text = `Enqueued: ${aheadInQueue.length} Job(s) ahead in queue`;
|
text = `Enqueued: ${aheadInQueue.length + 1} Job(s) ahead in queue`;
|
||||||
} else if (job.status == Status.PROCESSING) {
|
} else if (job.status == Status.PROCESSING) {
|
||||||
text = `Currently Processing\n${job.logs}`;
|
text = `Currently Processing\n${job.logs}`;
|
||||||
} else if (job.status == Status.COMPLETE) {
|
} else if (job.status == Status.COMPLETE) {
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@ from os import environ as env
|
||||||
from os import unlink as rm
|
from os import unlink as rm
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from typing import List
|
from typing import List
|
||||||
from urllib3.exceptions import ProtocolError
|
|
||||||
import requests
|
import requests
|
||||||
|
from urllib3.exceptions import ProtocolError, ReadTimeoutError
|
||||||
|
|
||||||
import curse_api as cf
|
import curse_api as cf
|
||||||
from common import Job, Status
|
from common import Job, Status
|
||||||
|
|
@ -90,6 +91,8 @@ class FastProvider(MgmtApiLogger):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
tries, msg = 1, ""
|
||||||
|
while tries <= 5:
|
||||||
try:
|
try:
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
"https://api.modrinth.com/v2/version",
|
"https://api.modrinth.com/v2/version",
|
||||||
|
|
@ -115,12 +118,17 @@ class FastProvider(MgmtApiLogger):
|
||||||
)
|
)
|
||||||
|
|
||||||
rm(jar_fn)
|
rm(jar_fn)
|
||||||
except (ProtocolError, requests.exceptions.ChunkedEncodingError):
|
break
|
||||||
self.logmsg(f"🔥 Uploading {display_nm} to Modrinth failed, skipping..")
|
except (ReadTimeoutError, TimeoutError):
|
||||||
statuses.append(Status.FAIL)
|
tries += 1
|
||||||
|
msg = f"🕜 Timed out uploading {jar_fn}. Manual upload required"
|
||||||
continue
|
continue
|
||||||
except TimeoutError:
|
except (ProtocolError, requests.exceptions.ChunkedEncodingError):
|
||||||
self.logmsg(f"🕜 Timed out uploading {jar_fn}. Manual upload required")
|
tries += 1
|
||||||
|
msg = f"🔥 Uploading {display_nm} to Modrinth failed, skipping.."
|
||||||
|
continue
|
||||||
|
if tries == 5:
|
||||||
|
self.logmsg(msg)
|
||||||
statuses.append(Status.FAIL)
|
statuses.append(Status.FAIL)
|
||||||
# endregion UPLOAD JAR FILE
|
# endregion UPLOAD JAR FILE
|
||||||
return statuses
|
return statuses
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ from selenium.webdriver.chrome.service import Service
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from urllib3.exceptions import ProtocolError, ReadTimeoutError
|
||||||
from webdriver_manager.chrome import ChromeDriverManager
|
from webdriver_manager.chrome import ChromeDriverManager
|
||||||
|
|
||||||
import curse_api as cf
|
import curse_api as cf
|
||||||
|
|
@ -212,6 +213,8 @@ class SlowProvider(MgmtApiLogger):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
tries, msg = 1, ""
|
||||||
|
while tries <= 5:
|
||||||
try:
|
try:
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
"https://api.modrinth.com/v2/version",
|
"https://api.modrinth.com/v2/version",
|
||||||
|
|
@ -237,10 +240,18 @@ class SlowProvider(MgmtApiLogger):
|
||||||
)
|
)
|
||||||
|
|
||||||
rm(f"./out/{self._job.curseforge_slug}/{fpath}")
|
rm(f"./out/{self._job.curseforge_slug}/{fpath}")
|
||||||
except TimeoutError:
|
break
|
||||||
self.logmsg(f"🕜 Timed out uploading {fpath}. Manual upload required")
|
except (ReadTimeoutError, TimeoutError):
|
||||||
|
tries += 1
|
||||||
|
msg = f"🕜 Timed out uploading {fpath}. Manual upload required"
|
||||||
|
continue
|
||||||
|
except (ProtocolError, requests.exceptions.ChunkedEncodingError):
|
||||||
|
tries += 1
|
||||||
|
msg = f"🔥 Uploading {display_nm} to Modrinth failed, skipping.."
|
||||||
|
continue
|
||||||
|
if tries == 5:
|
||||||
|
self.logmsg(msg)
|
||||||
statuses.append(Status.FAIL)
|
statuses.append(Status.FAIL)
|
||||||
|
|
||||||
# endregion UPLOAD THE MOD
|
# endregion UPLOAD THE MOD
|
||||||
|
|
||||||
any_succ = len(list(filter(lambda x: x == Status.SUCCESS, statuses))) > 0
|
any_succ = len(list(filter(lambda x: x == Status.SUCCESS, statuses))) > 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue