Integrate cdp_queue into CDP path
All CDP sessions now go through per-node queue (max 2 concurrent, priority levels). DM sends use high priority. Graceful fallback if module unavailable. Session: sidechat/chromebox-ops
This commit is contained in:
@@ -27,6 +27,7 @@ Usage:
|
||||
dm.py thread --from opm --to 646 --target main "message"
|
||||
"""
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import time
|
||||
@@ -47,8 +48,12 @@ def log_event(event):
|
||||
with open(LOG_FILE, "a") as f:
|
||||
f.write(json.dumps(event) + "\n")
|
||||
|
||||
def run(cmd, timeout=60):
|
||||
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout)
|
||||
def run(cmd, timeout=60, priority=None):
|
||||
# priority: CDP queue priority for the subprocess (high/normal/low).
|
||||
# DM sends are user-facing -> high. Reads stay at default (normal).
|
||||
env = dict(os.environ, CDP_PRIORITY=priority) if priority else None
|
||||
result = subprocess.run(cmd, shell=True, capture_output=True, text=True,
|
||||
timeout=timeout, env=env)
|
||||
return result.stdout.strip()
|
||||
|
||||
def run_full(cmd, timeout=60):
|
||||
@@ -105,7 +110,8 @@ def dm_send(agent, target, message, verify=True, raw=False, to_agent=None):
|
||||
max_retries = 3
|
||||
delivered = False
|
||||
for attempt in range(max_retries):
|
||||
run(f'{NETVM_EXEC} {recipient} -- python3 {API} --account {recipient} send "{safe}"')
|
||||
run(f'{NETVM_EXEC} {recipient} -- python3 {API} --account {recipient} send "{safe}"',
|
||||
priority="high")
|
||||
time.sleep(3) # Wait for message to propagate
|
||||
|
||||
# Verify by reading recipient's chat (independent check, not local echo)
|
||||
|
||||
Reference in New Issue
Block a user