Skip to content

[Bug] sglrouter bug: Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context. #7901

@chengmengli06

Description

@chengmengli06

Checklist

  • 1. I have searched related issues but cannot get the expected help.
  • 2. The bug has not been fixed in the latest version.
  • 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.
  • 4. If the issue you raised is not a bug but a question, please raise a discussion at https://github.com/sgl-project/sglang/discussions/new/choose Otherwise, it will be closed.
  • 5. Please use English, otherwise it will be closed.

Describe the bug

python3 -m sglang_router.launch_router --pd-disaggregation --policy cache_aware --prefill http://22.17.104.105:30000 none --prefill http://22.11.174.37:30000 none --prefill http://22.12.58.159:30000 none --prefill http://22.11.243.185:30000 none --prefill http://22.12.13.194:30000 none --prefill http://22.12.25.127:30000 none --prefill http://22.11.161.15:30000 none --prefill http://22.17.106.29:30000 none --prefill http://22.12.56.224:30000 none --prefill http://22.12.32.35:30000 none --prefill http://22.13.53.194:30000 none --prefill http://22.12.1.151:30000 none --decode http://22.11.254.147:30000
2025-07-09 13:08:36 INFO sglang_router_rs::server: src/server.rs:312: 🚧 Initializing Prometheus metrics on 127.0.0.1:29000
2025-07-09 13:08:36 INFO sglang_router_rs::server: src/server.rs:321: 🚧 Initializing router on 127.0.0.1:30000
2025-07-09 13:08:36 INFO sglang_router_rs::server: src/server.rs:322: 🚧 Initializing workers on []
2025-07-09 13:08:36 INFO sglang_router_rs::server: src/server.rs:323: 🚧 Policy Config: PrefillDecodeConfig { selection_policy: CacheAware { cache_threshold: 0.5, balance_abs_threshold: 32, balance_rel_threshold: 1.0001 }, prefill_urls: [("http://22.17.104.105:30000", None), ("http://22.11.174.37:30000", None), ("http://22.12.58.159:30000", None), ("http://22.11.243.185:30000", None), ("http://22.12.13.194:30000", None), ("http://22.12.25.127:30000", None), ("http://22.11.161.15:30000", None), ("http://22.17.106.29:30000", None), ("http://22.12.56.224:30000", None), ("http://22.12.32.35:30000", None), ("http://22.13.53.194:30000", None), ("http://22.12.1.151:30000", None)], decode_urls: ["http://22.11.254.147:30000"], timeout_secs: 300, interval_secs: 10 }
2025-07-09 13:08:36 INFO sglang_router_rs::server: src/server.rs:324: 🚧 Max payload size: 256 MB
2025-07-09 13:08:36 INFO sglang_router_rs::server: src/server.rs:334: 🚧 Service discovery disabled

thread '' panicked at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/blocking/shutdown.rs:51:21:
Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.
stack backtrace:
0: 0x7fb73afbb082 - std::backtrace_rs::backtrace::libunwind::trace::h74680e970b6e0712
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
1: 0x7fb73afbb082 - std::backtrace_rs::backtrace::trace_unsynchronized::ha3bf590e3565a312
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14
2: 0x7fb73afbb082 - std::sys::backtrace::print_fmt::hcf16024cbdd6c458
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/sys/backtrace.rs:66:9
3: 0x7fb73afbb082 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h46a716bba2450163
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/sys/backtrace.rs:39:26
4: 0x7fb73afe52d3 - core::fmt::rt::Argument::fmt::ha695e732309707b7
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/fmt/rt.rs:181:76
5: 0x7fb73afe52d3 - core::fmt::write::h275e5980d7008551
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/fmt/mod.rs:1446:25
6: 0x7fb73afb7803 - std::io::default_write_fmt::hdc4119be3eb77042
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/io/mod.rs:639:11
7: 0x7fb73afb7803 - std::io::Write::write_fmt::h561a66a0340b6995
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/io/mod.rs:1914:13
8: 0x7fb73afbaed2 - std::sys::backtrace::BacktraceLock::print::hafb9d5969adc39a0
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/sys/backtrace.rs:42:9
9: 0x7fb73afbcb52 - std::panicking::default_hook::{{closure}}::hae2e97a5c4b2b777
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:300:22
10: 0x7fb73afbc955 - std::panicking::default_hook::h3db1b505cfc4eb79
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:327:9
11: 0x7fb73afbd4f2 - std::panicking::rust_panic_with_hook::h409da73ddef13937
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:833:13
12: 0x7fb73afbd266 - std::panicking::begin_panic_handler::{{closure}}::h159b61b27f96a9c2
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:699:13
13: 0x7fb73afbb579 - std::sys::backtrace::rust_end_short_backtrace::h5b56844d75e766fc
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/sys/backtrace.rs:168:18
14: 0x7fb73afbcf2d - rustc[4794b31dd7191200]::rust_begin_unwind
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:697:5
15: 0x7fb73926e710 - core::panicking::panic_fmt::hc8737e8cca20a7c8
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/panicking.rs:75:14
16: 0x7fb73aa4174d - tokio::runtime::blocking::shutdown::Receiver::wait::h5f4c66d4c69332f1
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/blocking/shutdown.rs:51:21
17: 0x7fb73aa49fa5 - tokio::runtime::blocking::pool::BlockingPool::shutdown::hcf819cf11712a374
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/blocking/pool.rs:263:12
18: 0x7fb73aa4a24e - <tokio::runtime::blocking::pool::BlockingPool as core::ops::drop::Drop>::drop::h1a1bfc6cef99872a
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/blocking/pool.rs:284:9
19: 0x7fb73aa543a7 - core::ptr::drop_in_placetokio::runtime::blocking::pool::BlockingPool::h999ad7a9e2dca0b8
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/ptr/mod.rs:524:1
20: 0x7fb73aa536e4 - core::ptr::drop_in_placetokio::runtime::runtime::Runtime::h38660d2cb2ca80ae
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/ptr/mod.rs:524:1
21: 0x7fb739ed932d - reqwest::blocking::wait::enter::h0ea38540cde0ba0d
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-0.12.22/src/blocking/wait.rs:80:21
22: 0x7fb739ed70b6 - reqwest::blocking::wait::timeout::h3ccb65c091f7b30c
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-0.12.22/src/blocking/wait.rs:13:5
23: 0x7fb739e41ca9 - reqwest::blocking::client::ClientHandle::new::h9bc89b24f67b0391
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-0.12.22/src/blocking/client.rs:1291:15
24: 0x7fb739e41467 - reqwest::blocking::client::ClientBuilder::build::h1d5e53974dc9afdc
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-0.12.22/src/blocking/client.rs:114:9
25: 0x7fb7396a2659 - sglang_router_rs::router::Router::wait_for_healthy_workers::hee2d9a52d3a5ed31
at /root/sglang/sgl-router/src/router.rs:319:27
26: 0x7fb7394af227 - sglang_router_rs::pd_router::PDRouter::new::hf603ebd66d3a8a81
at /root/sglang/sgl-router/src/pd_router.rs:234:9
27: 0x7fb7396a1650 - sglang_router_rs::router::Router::new::h9d5b1ebdc8a85ca6
at /root/sglang/sgl-router/src/router.rs:285:33
28: 0x7fb739554a83 - sglang_router_rs::server::AppState::new::h8ff9453a9b0edd82
at /root/sglang/sgl-router/src/server.rs:37:31
29: 0x7fb739527987 - sglang_router_rs::server::startup::{{closure}}::h646c8b0d3c167656
at /root/sglang/sgl-router/src/server.rs:343:26
30: 0x7fb73939e83b - sglang_router_rs::Router::start::{{closure}}::h0ec3efffa2646dea
at /root/sglang/sgl-router/src/lib.rs:293:14
31: 0x7fb7393b0ceb - <core::pin::Pin

as core::future::future::Future>::poll::h747d38dc7ad4c128
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/future/future.rs:124:9
32: 0x7fb73936145e - tokio::runtime::park::CachedParkThread::block_on::{{closure}}::h16aec94800eb8f6b
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/park.rs:285:60
33: 0x7fb739360978 - tokio::task::coop::with_budget::h5f91502033ffeea0
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/task/coop/mod.rs:167:5
34: 0x7fb739360978 - tokio::task::coop::budget::h7f7058137406f24d
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/task/coop/mod.rs:133:5
35: 0x7fb739360978 - tokio::runtime::park::CachedParkThread::block_on::h7295860e335bff83
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/park.rs:285:31
36: 0x7fb7394c426f - tokio::runtime::context::blocking::BlockingRegionGuard::block_on::h68db836754604584
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/context/blocking.rs:66:9
37: 0x7fb7393e10bd - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}::h0aeaa26e66b39a3c
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/scheduler/multi_thread/mod.rs:87:13
38: 0x7fb7392ae362 - tokio::runtime::context::runtime::enter_runtime::h12276441e44264e8
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/context/runtime.rs:65:16
39: 0x7fb7393e1007 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::h6581706ba2ea6e62
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/scheduler/multi_thread/mod.rs:86:9
40: 0x7fb7397a79e2 - tokio::runtime::runtime::Runtime::block_on_inner::he389411866a20360
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/runtime.rs:358:45
41: 0x7fb7397a7cdb - tokio::runtime::runtime::Runtime::block_on::h0a6d6f463607c724
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/runtime.rs:328:13
42: 0x7fb7393868b8 - sglang_router_rs::Router::start::hde259c8baf10e0a3
at /root/sglang/sgl-router/src/lib.rs:280:9
43: 0x7fb73938b1d1 - sglang_router_rs::Router::pymethod_start::hdeb1a16623985cbe
at /root/sglang/sgl-router/src/lib.rs:137:1
44: 0x7fb739520168 - pyo3::impl
::trampoline::noargs::{{closure}}::hc69ea84a76e7ad54
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-0.22.6/src/impl
/trampoline.rs:34:21
45: 0x7fb73951fd0b - pyo3::impl
::trampoline::trampoline::{{closure}}::haf316cf206c6dbae
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-0.22.6/src/impl/trampoline.rs:188:54
46: 0x7fb7395fb503 - std::panicking::try::do_call::h41e1eb5ea418e28f
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:589:40
47: 0x7fb73968021b - rust_try
48: 0x7fb73967c0ad - std::panicking::try::h7038403d4e3b880c
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:552:19
49: 0x7fb73967c0ad - std::panic::catch_unwind::h09b2f584916f0e50
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panic.rs:359:14
50: 0x7fb73951f98e - pyo3::impl
::trampoline::trampoline::h68dffc7b80a25077
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-0.22.6/src/impl
/trampoline.rs:188:9
51: 0x7fb739368df2 - pyo3::impl::trampoline::noargs::h3b053ba75c8b8beb
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-0.22.6/src/impl_/trampoline.rs:34:5
52: 0x7fb7393869ea - sglang_router_rs::<impl pyo3::impl_::pyclass::PyMethods<sglang_router_rs::Router> for pyo3::impl_::pyclass::PyClassImplCollector<sglang_router_rs::Router>>::py_methods::ITEMS::trampoline::hdd6ee60f36cde10e
at /root/sglang/sgl-router/src/lib.rs:137:1
53: 0x551711 -
54: 0x549b85 - PyObject_Vectorcall
55: 0x5d73c9 - _PyEval_EvalFrameDefault
56: 0x5d58eb - PyEval_EvalCode
57: 0x5d347c -
58: 0x581f0d -
59: 0x549b85 - PyObject_Vectorcall
60: 0x5d73c9 - _PyEval_EvalFrameDefault
61: 0x6bcce2 -
62: 0x6bc912 - Py_RunMain
63: 0x6bc57d - Py_BytesMain
64: 0x7fb73be2a1ca -
65: 0x7fb73be2a28b - __libc_start_main
66: 0x657ce5 - _start
67: 0x0 -
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/root/sglang/sgl-router/py_src/sglang_router/launch_router.py", line 475, in
main()
File "/root/sglang/sgl-router/py_src/sglang_router/launch_router.py", line 471, in main
launch_router(router_args)
File "/root/sglang/sgl-router/py_src/sglang_router/launch_router.py", line 426, in launch_router
router.start()
File "/root/sglang/sgl-router/py_src/sglang_router/router.py", line 123, in start
self._router.start()
pyo3_runtime.PanicException: Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.

Reproduction

python3 -m sglang_router.launch_router --pd-disaggregation --policy cache_aware --prefill http://22.17.104.105:30000 none --prefill http://22.11.174.37:30000 none --prefill http://22.12.58.159:30000 none --prefill http://22.11.243.185:30000 none --prefill http://22.12.13.194:30000 none --prefill http://22.12.25.127:30000 none --prefill http://22.11.161.15:30000 none --prefill http://22.17.106.29:30000 none --prefill http://22.12.56.224:30000 none --prefill http://22.12.32.35:30000 none --prefill http://22.13.53.194:30000 none --prefill http://22.12.1.151:30000 none --decode http://22.11.254.147:30000

Environment

sglang latest version

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions