-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfind_new_issue.py
More file actions
36 lines (31 loc) · 1.18 KB
/
find_new_issue.py
File metadata and controls
36 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import argparse
import os
import threading
from concurrent.futures import as_completed
from concurrent.futures import ThreadPoolExecutor
from random import randint
from tests.test_invalid_ast import generate_invalid_ast
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--seed", type=int, help="Test only one seed value")
parser.add_argument(
"--workers", type=int, default=os.cpu_count(), help="Number of parallel workers"
)
args = parser.parse_args()
if args.seed is not None:
print(f"Testing seed {args.seed}")
generate_invalid_ast(args.seed)
else:
found = threading.Event()
def try_seed():
while not found.is_set():
i = randint(0, 10000000000)
if generate_invalid_ast(i):
found.set()
print(f"Found seed: {i}")
return i
with ThreadPoolExecutor(max_workers=args.workers) as executor:
futures = [executor.submit(try_seed) for _ in range(args.workers)]
for future in as_completed(futures):
if future.result() is not None:
break