MCPcopy
hub / github.com/benoitc/gunicorn / start

Method start

benchmarks/dirty_benchmark.py:217–256  ·  view source on GitHub ↗

Start the dirty arbiter and workers.

(self)

Source from the content-addressed store, hash-verified

215 self._tmpdir = None
216
217 def start(self):
218 """Start the dirty arbiter and workers."""
219 # Create temp directory for socket
220 self._tmpdir = tempfile.mkdtemp(prefix="dirty-bench-")
221 self.socket_path = os.path.join(self._tmpdir, "arbiter.sock")
222
223 # Create config and logger
224 cfg = MockConfig(
225 dirty_apps=[BENCHMARK_APP],
226 dirty_workers=self.dirty_workers,
227 dirty_threads=self.dirty_threads,
228 dirty_timeout=self.dirty_timeout,
229 )
230 log = MockLogger(verbose=self.verbose)
231
232 # Fork arbiter process
233 pid = os.fork()
234 if pid == 0:
235 # Child process - run arbiter
236 try:
237 arbiter = DirtyArbiter(cfg, log, socket_path=self.socket_path)
238 arbiter.run()
239 except Exception as e:
240 print(f"Arbiter error: {e}")
241 finally:
242 os._exit(0)
243
244 # Parent process
245 self.arbiter_pid = pid
246
247 # Wait for arbiter socket to be ready
248 for _ in range(50): # 5 seconds max
249 if os.path.exists(self.socket_path):
250 break
251 time.sleep(0.1)
252 else:
253 raise RuntimeError("Arbiter socket not ready")
254
255 # Give workers time to start
256 time.sleep(0.5)
257
258 def stop(self):
259 """Stop the dirty arbiter."""

Callers 9

run_isolated_suiteFunction · 0.95
run_payload_suiteFunction · 0.95
run_quick_testFunction · 0.95
run_config_sweepFunction · 0.95
mainFunction · 0.95

Calls 5

runMethod · 0.95
DirtyArbiterClass · 0.90
MockLoggerClass · 0.85
existsMethod · 0.80
MockConfigClass · 0.70

Tested by

no test coverage detected