Use threading.TIMEOUT_MAX when available (#32399)

This value was introduced in Python 3.2. Specifying a timeout greater than
this value will raise an OverflowError.
This commit is contained in:
Betsy McPhail
2022-08-26 19:37:56 -04:00
committed by GitHub
parent 59bfa6bcd3
commit ad95719a1d

View File

@@ -71,6 +71,8 @@
import re
import math
import multiprocessing
import sys
import threading
import time
from contextlib import contextmanager
@@ -409,7 +411,12 @@ def parse(self, stream, context=6, jobs=None):
pool = multiprocessing.Pool(jobs)
try:
# this is a workaround for a Python bug in Pool with ctrl-C
results = pool.map_async(_parse_unpack, args, 1).get(9999999)
if sys.version_info >= (3, 2):
max_timeout = threading.TIMEOUT_MAX
else:
max_timeout = 9999999
results = pool.map_async(_parse_unpack, args, 1).get(max_timeout)
errors, warnings, timings = zip(*results)
finally:
pool.terminate()