{"record":{"id":"9378a79e2fe50c6b","repo":"pola-rs/polars","slug":"integer","errorCode":null,"errorMessage":"integer","messagePattern":"integer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/polars-async/src/lib.rs","lineNumber":19,"sourceCode":"use std::sync::{Arc, LazyLock};\n\nuse polars_error::polars_warn;\nuse polars_utils::relaxed_cell::RelaxedCell;\nuse tokio::runtime::{Builder, Runtime};\n\nuse crate::executor::{THREAD_SPAWNED_BY_POLARS_EXECUTOR, is_scheduling_polars_executor_thread};\n\npub mod executor;\npub mod primitives;\n\npub struct RuntimeManager {\n    rt: Runtime,\n}\n\nimpl RuntimeManager {\n    fn new() -> Self {\n        let n_threads = std::env::var(\"POLARS_ASYNC_THREAD_COUNT\")\n            .map(|x| x.parse::<usize>().expect(\"integer\"))\n            .unwrap_or(usize::min(polars_config::config().max_threads(), 32));\n\n        let max_blocking = std::env::var(\"POLARS_MAX_BLOCKING_THREAD_COUNT\")\n            .map(|x| x.parse::<usize>().expect(\"integer\"))\n            .unwrap_or(512);\n\n        if polars_config::config().verbose() {\n            eprintln!(\"async thread count: {n_threads}\");\n            eprintln!(\"blocking thread count: {max_blocking}\");\n        }\n\n        let max_total_threads = n_threads + max_blocking;\n        let warned = RelaxedCell::new_bool(false);\n        let tokio_thread_count_start = Arc::new(RelaxedCell::new_i64(0));\n        let tokio_thread_count_stop = tokio_thread_count_start.clone();\n\n        let rt = Builder::new_multi_thread()\n            .worker_threads(n_threads)","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/crates/polars-async/src/lib.rs#L1-L37","documentation":"RuntimeManager::new reads POLARS_ASYNC_THREAD_COUNT (line 19) and POLARS_MAX_BLOCKING_THREAD_COUNT, calling parse::<usize>().expect(\"integer\"). Any value that is not a bare unsigned integer - floats, negative numbers, whitespace, empty string - panics. The manager initializes lazily on first async use, so the panic surfaces far from the env var that caused it.","triggerScenarios":"First use of Polars' async runtime (cloud reads, async globbing, async engine) with POLARS_ASYNC_THREAD_COUNT set to values like '4.0', ' 4', '-1', or '' (empty interpolation).","commonSituations":".env / docker-compose entries with quotes or trailing whitespace; shell scripts interpolating unset variables to empty strings; copy-pasted configs expecting float thread counts; CI injecting stray values.","solutions":["Fix the value to a plain decimal integer: export POLARS_ASYNC_THREAD_COUNT=8","Or simply unset it - Polars then defaults to min(max_threads, 32)","Audit sibling variable POLARS_MAX_BLOCKING_THREAD_COUNT, which fails identically","Check for literal quotes, spaces, 'K'-suffixes, or negative signs in the env value"],"exampleFix":"# before\nexport POLARS_ASYNC_THREAD_COUNT=\"8 \"   # trailing space -> parse fails\n\n# after\nexport POLARS_ASYNC_THREAD_COUNT=8","handlingStrategy":"validation","validationCode":"// Rust: verify before any async work\nfor var in [\"POLARS_ASYNC_THREAD_COUNT\", \"POLARS_MAX_BLOCKING_THREAD_COUNT\"] {\n    if let Ok(v) = std::env::var(var) {\n        assert!(v.parse::<usize>().is_ok(), \"{var} must be a plain integer, got {v:?}\");\n    }\n}\n\n# Shell: fail fast in entrypoints\n[ -z \"${POLARS_ASYNC_THREAD_COUNT:-}\" ] || [[ \"$POLARS_ASYNC_THREAD_COUNT\" =~ ^[0-9]+$ ]] \\\n  || { echo \"POLARS_ASYNC_THREAD_COUNT must be an integer\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set thread-count env vars to bare decimal integers or leave them unset","Quote-check .env/docker-compose values for stray spaces and quotes","Guard empty interpolations: :-${var:-} patterns can inject '' ","Validate both POLARS_ASYNC_THREAD_COUNT and POLARS_MAX_BLOCKING_THREAD_COUNT in container entrypoints"],"tags":["rust","polars","environment","configuration","async","panic"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}