{
  "id": "rust/tokio-runtime-shutdown-timeout",
  "signature": "thread 'tokio-runtime-worker' panicked at 'Cannot drop a runtime in a context where blocking is not allowed'",
  "signature_zh": "线程'tokio-runtime-worker'在'不允许阻塞的上下文中无法丢弃运行时'处panic",
  "regex": "thread '[a-zA-Z_\\-]+' panicked at 'Cannot drop a runtime in a context where blocking is not allowed'",
  "domain": "rust",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Attempting to drop a Tokio runtime inside an asynchronous context (e.g., inside a future or task) where blocking is prohibited, often due to incorrect runtime nesting or shutdown.",
  "root_cause_type": "generic",
  "root_cause_zh": "在异步上下文（例如future或task）中尝试丢弃Tokio运行时，而该上下文禁止阻塞操作，通常是由于运行时嵌套或关闭不正确。",
  "versions": [
    {
      "version": "tokio 1.25.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tokio 1.30.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tokio 1.35.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Forgetting the runtime leaks resources and doesn't fix the underlying issue; the panic still occurs on drop.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The panic is caused by the drop logic, not by ownership; Arc doesn't prevent the drop from happening.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "`block_on` itself blocks, which may trigger the same panic if called from an async context.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the runtime is dropped outside of any async context, e.g., by storing it in a struct and dropping it in a synchronous scope.",
      "success_rate": 0.85,
      "how": "Ensure the runtime is dropped outside of any async context, e.g., by storing it in a struct and dropping it in a synchronous scope.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `tokio::runtime::Runtime::shutdown_timeout` to gracefully shut down before dropping.",
      "success_rate": 0.8,
      "how": "Use `tokio::runtime::Runtime::shutdown_timeout` to gracefully shut down before dropping.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保运行时在任何异步上下文之外被丢弃，例如将其存储在结构体中，并在同步作用域中丢弃。",
    "使用`tokio::runtime::Runtime::shutdown_timeout`在丢弃前优雅关闭。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.rs/tokio/latest/tokio/runtime/struct.Runtime.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2024-01-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}