{"record":{"id":"80eb31fcf538ab91","repo":"sgl-project/sglang","slug":"timeout-while-waiting-for-event-name","errorCode":null,"errorMessage":"Timeout while waiting for event '{name}'","messagePattern":"Timeout while waiting for event '(.+?)'","errorType":"error_code","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"python/sglang/lang/interpreter.py","lineNumber":366,"sourceCode":"            self._execute(expr)\n\n    def sync(self):\n        if self.use_thread:\n            self.queue.join()\n\n    def get_var(self, name):\n        if name in self.variable_event:\n            self.variable_event[name].wait()\n        return self.variables[name]\n\n    def set_var(self, name, value):\n        self.variables[name] = value\n\n    def get_meta_info(self, name, timeout=None):\n        if name in self.variable_event:\n            got = self.variable_event[name].wait(timeout)\n            if not got:\n                raise TimeoutError(f\"Timeout while waiting for event '{name}'\")\n        ret = self.meta_info.get(name, None)\n        return ret\n\n    def fork(\n        self,\n        size: int = 1,\n        position_ids_offset: Optional[List[int]] = None,\n    ):\n        if size > 1 and str(self.text_):\n            self.submit(SglCommitLazy())\n\n        self.sync()\n        size = int(size)\n\n        exes = [\n            StreamExecutor(\n                self.backend,\n                self.arguments,","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/lang/interpreter.py#L348-L384","documentation":"Raised by ProgramExecutor.get_meta_info when waiting on a variable's event for `timeout` seconds without the variable being set. In SGL's async interpreter, meta info (finish reason, completion tokens, etc.) is published when a named generation completes; timing out means the producer never set that variable.","triggerScenarios":"Calling get_meta_info(name, timeout=N) where `name` was never bound by a select/gen with that name, the generating branch errored out before setting the variable, or the timeout is shorter than model latency (especially with forked/parallel branches).","commonSituations":"Retrieving meta info for a variable whose generation failed silently; fork() branches racing with the main thread; too-aggressive timeouts under load or long max_new_tokens; typo in the variable name.","solutions":["Increase or omit the timeout (blocking wait) if generation is legitimately slow","Verify the variable name matches an actual `name=` on a gen/select in the SGL program","Check for exceptions in the executor thread/branch that would prevent the variable from ever being set","Pass timeout=None to wait indefinitely when correctness matters more than latency"],"exampleFix":"# before\nmeta = state.get_meta_info(\"answer\", timeout=1)\n# after\nmeta = state.get_meta_info(\"answer\", timeout=30)  # or None to block until set","handlingStrategy":"retry","validationCode":"# before waiting, confirm the variable will be produced\nassert name in state.stream_executor.variables or name in declared_gen_names, f\"{name} is never set\"","typeGuard":null,"tryCatchPattern":"try:\n    meta = state.get_meta_info(name, timeout=30)\nexcept TimeoutError:\n    logger.warning(\"%s not ready; retrying\", name)\n    meta = state.get_meta_info(name, timeout=60)","preventionTips":["Use timeout=None for must-have values","Ensure every name passed to get_meta_info is bound by a gen/select in the program","Watch executor logs for branch exceptions that leave variables unset"],"tags":["timeout","concurrency","async","meta-info"],"backgroundTag":"wait-timeout","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}