| 123 | |
| 124 | class DBBench(Task[Dict, Dict[str, Any], str]): |
| 125 | def __init__(self, **configs): |
| 126 | super().__init__(**configs) |
| 127 | self.data_file = configs.pop("data_file") |
| 128 | self.max_round = configs.pop("max_round", 5) |
| 129 | self.processes = [] |
| 130 | ctx = mp.get_context('spawn') |
| 131 | for i in range(self.workers): |
| 132 | receiver, sender = ctx.Pipe(False) |
| 133 | p = ctx.Process(target=process, args=(receiver, self.max_round)) |
| 134 | p.start() |
| 135 | self.processes.append((sender, ctx.Lock(), p)) |
| 136 | |
| 137 | def escape(self, string: str, conn=None): |
| 138 | conn = conn or self.conn |