MCPcopy
hub / github.com/HKUDS/DeepCode / cleanup_processes

Function cleanup_processes

deepcode.py:293–336  Ā·  view source on GitHub ↗

Clean up running processes

()

Source from the content-addressed store, hash-verified

291
292
293def cleanup_processes():
294 """Clean up running processes"""
295 global _backend_process, _frontend_process
296
297 print("\nšŸ›‘ Stopping services...")
298
299 for name, proc in [("Backend", _backend_process), ("Frontend", _frontend_process)]:
300 if proc and proc.poll() is None:
301 try:
302 if get_platform() == "windows":
303 # Windows: use taskkill with /T to kill tree
304 subprocess.run(
305 f"taskkill /F /T /PID {proc.pid}",
306 shell=True,
307 capture_output=True,
308 )
309 else:
310 # Unix: kill the process group
311 try:
312 os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
313 proc.wait(timeout=5)
314 except Exception:
315 os.killpg(os.getpgid(proc.pid), signal.SIGKILL)
316 print(f" āœ“ {name} stopped")
317 except Exception:
318 # Fallback: try direct terminate
319 try:
320 proc.terminate()
321 proc.wait(timeout=3)
322 print(f" āœ“ {name} stopped")
323 except Exception:
324 try:
325 proc.kill()
326 print(f" āœ“ {name} killed")
327 except Exception:
328 print(f" āš ļø Could not stop {name}")
329
330 # Also clean up any orphaned processes on ports
331 time.sleep(0.5)
332 for port in [8000, 5173]:
333 if is_port_in_use(port):
334 kill_process_on_port(port)
335
336 print("āœ… All services stopped")
337
338
339def cleanup_cache():

Callers 1

mainFunction Ā· 0.85

Calls 4

get_platformFunction Ā· 0.85
is_port_in_useFunction Ā· 0.85
kill_process_on_portFunction Ā· 0.85
runMethod Ā· 0.80

Tested by

no test coverage detected