diff --git a/manticore/ethereum/manticore.py b/manticore/ethereum/manticore.py index a303dc6c3..d218ac032 100644 --- a/manticore/ethereum/manticore.py +++ b/manticore/ethereum/manticore.py @@ -3,7 +3,8 @@ import logging from multiprocessing import Queue, Process from queue import Empty as EmptyQueue -from typing import Dict, Optional, Union +import threading +from typing import Callable, Dict, Optional, Tuple, Union import io import pyevmasm as EVMAsm import random @@ -1757,13 +1758,34 @@ def worker_finalize(q): except EmptyQueue: pass + class ReportWorkerSingle: + """Run task in the current process and current thread""" + + def __init__(self, target: Callable, args: Tuple) -> None: + self.target = target + self.args = args + + def start(self) -> None: + self.target(*self.args) + + def join(self) -> None: + pass + # Generate testcases for all but killed states q = Queue() for state_id in self._all_states: # we need to remove -1 state before forking because it may be in memory q.put(state_id) - report_workers = [Process(target=worker_finalize, args=(q,)) for _ in range(procs)] + core_consts = config.get_group("core") + report_workers = [ + { + core_consts.mprocessing.single: ReportWorkerSingle, + core_consts.mprocessing.threading: threading.Thread, + core_consts.mprocessing.multiprocessing: Process, + }[core_consts.mprocessing](target=worker_finalize, args=(q,)) + for _ in range(procs) + ] for proc in report_workers: proc.start()