1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-26 14:46:16 +00:00

Handle multiprocessing exceptions in extract_assets.py (#925)

* Handle multiprocessing exceptions in extract_assets.py

* Update extract_assets.py

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>

* Add TypeError

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
Anghelo Carvajal 2021-08-29 20:19:52 -04:00 committed by GitHub
parent a75c70358c
commit e9f98f44c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import argparse
from multiprocessing import Pool, cpu_count, Event, Manager
from multiprocessing import Pool, cpu_count, Event, Manager, ProcessError
import os
import json
import time
@ -103,10 +103,18 @@ def main():
if file.endswith(".xml"):
xmlFiles.append(fullPath)
numCores = cpu_count()
print("Extracting assets with " + str(numCores) + " CPU cores.")
with Pool(numCores, initializer=initializeWorker, initargs=(mainAbort, args.unaccounted, extractedAssetsTracker, manager)) as p:
p.map(ExtractFunc, xmlFiles)
try:
numCores = cpu_count()
print("Extracting assets with " + str(numCores) + " CPU cores.")
with Pool(numCores, initializer=initializeWorker, initargs=(mainAbort, args.unaccounted, extractedAssetsTracker, manager)) as p:
p.map(ExtractFunc, xmlFiles)
except (ProcessError, TypeError):
print("Warning: Multiprocessing exception ocurred.", file=os.sys.stderr)
print("Disabling mutliprocessing.", file=os.sys.stderr)
initializeWorker(mainAbort, args.unaccounted, extractedAssetsTracker, manager)
for singlePath in xmlFiles:
ExtractFunc(singlePath)
with open(EXTRACTED_ASSETS_NAMEFILE, 'w', encoding='utf-8') as f:
serializableDict = dict()