mirror of
https://github.com/quantum5/win2xcur.git
synced 2025-04-24 10:11:57 -04:00
Add parallel processing
This commit is contained in:
parent
a46bfd7916
commit
f13e4260d4
|
@ -2,6 +2,9 @@ import argparse
|
|||
import os
|
||||
import sys
|
||||
import traceback
|
||||
from multiprocessing import cpu_count
|
||||
from multiprocessing.pool import ThreadPool
|
||||
from threading import Lock
|
||||
|
||||
from win2xcur import shadow
|
||||
from win2xcur.parser import open_blob
|
||||
|
@ -30,15 +33,17 @@ def main() -> None:
|
|||
help='color of the shadow')
|
||||
|
||||
args = parser.parse_args()
|
||||
print_lock = Lock()
|
||||
|
||||
check_xcursorgen()
|
||||
|
||||
for file in args.files:
|
||||
def process(file):
|
||||
name = file.name
|
||||
blob = file.read()
|
||||
try:
|
||||
cursor = open_blob(blob)
|
||||
except Exception:
|
||||
with print_lock:
|
||||
print('Error occurred while processing %s:' % (name,), file=sys.stderr)
|
||||
traceback.print_exc()
|
||||
else:
|
||||
|
@ -50,6 +55,9 @@ def main() -> None:
|
|||
with open(output, 'wb') as f:
|
||||
f.write(result)
|
||||
|
||||
with ThreadPool(cpu_count()) as pool:
|
||||
pool.map(process, args.files)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue