MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / policy_worker

Function policy_worker

codeclash/arenas/scml/runtime/run_scml.py:187–220  ·  view source on GitHub ↗
(
    command_queue: mp.Queue, result_queue: mp.Queue, startup_queue: mp.Queue, player_name: str, path: str
)

Source from the content-addressed store, hash-verified

185
186
187def policy_worker(
188 command_queue: mp.Queue, result_queue: mp.Queue, startup_queue: mp.Queue, player_name: str, path: str
189) -> None:
190 try:
191 module = load_policy_module(player_name, path)
192 except BaseException as exc:
193 startup_queue.put(
194 {
195 "error": f"{type(exc).__name__}: {exc}",
196 "traceback": traceback.format_exc(limit=5),
197 }
198 )
199 return
200 startup_queue.put({"ready": True})
201
202 while True:
203 try:
204 request = command_queue.get()
205 except (EOFError, KeyboardInterrupt):
206 return
207 if request is None:
208 return
209 request_id = request["request_id"]
210 try:
211 decision = module.decide(request["observation"])
212 result_queue.put({"request_id": request_id, "decision": decision})
213 except BaseException as exc:
214 result_queue.put(
215 {
216 "request_id": request_id,
217 "error": f"{type(exc).__name__}: {exc}",
218 "traceback": traceback.format_exc(limit=5),
219 }
220 )
221
222
223class PolicyController:

Callers

nothing calls this directly

Calls 3

getMethod · 0.80
load_policy_moduleFunction · 0.70
decideMethod · 0.45

Tested by

no test coverage detected