{"record":{"id":"830263b3ed9dbc88","repo":"pola-rs/polars","slug":"gevent-is-required-for-using-lazyframe-collect-asy","errorCode":null,"errorMessage":"gevent is required for using LazyFrame.collect_async(gevent=True) orpolars.collect_all_async(gevent=True)","messagePattern":"gevent is required for using LazyFrame\\.collect_async\\(gevent=True\\) orpolars\\.collect_all_async\\(gevent=True\\)","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/_utils/async_.py","lineNumber":29,"sourceCode":"    from collections.abc import Generator\n\n    from polars import DataFrame\n    from polars._plr import PyDataFrame\n\n\nT = TypeVar(\"T\")\n\n\nclass _GeventDataFrameResult(Generic[T]):\n    __slots__ = (\"_result\", \"_value\", \"_watcher\")\n\n    def __init__(self) -> None:\n        if not _GEVENT_AVAILABLE:\n            msg = (\n                \"gevent is required for using LazyFrame.collect_async(gevent=True) or\"\n                \"polars.collect_all_async(gevent=True)\"\n            )\n            raise ImportError(msg)\n\n        from gevent.event import AsyncResult  # type: ignore[import-untyped]\n        from gevent.hub import get_hub  # type: ignore[import-untyped]\n\n        self._value: None | Exception | PyDataFrame | list[PyDataFrame] = None\n        self._result = AsyncResult()\n\n        self._watcher = get_hub().loop.async_()\n        self._watcher.start(self._watcher_callback)\n\n    def get(\n        self,\n        block: bool = True,  # noqa: FBT001\n        timeout: float | int | None = None,\n    ) -> T:\n        return self.result.get(block=block, timeout=timeout)\n\n    @property","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/_utils/async_.py#L11-L47","documentation":"Creating an AsyncDataFrame/collect callback wrapper with gevent=True requires the gevent package. When gevent is not importable, the wrapper's __init__ raises ImportError explaining that LazyFrame.collect_async(gevent=True) and polars.collect_all_async(gevent=True) need it.","triggerScenarios":"Calling LazyFrame.collect_async(gevent=True) or polars.collect_all_async(gevent=True) in an environment where gevent is not installed.","commonSituations":"Deploying async-collection code to production images that omit the gevent extra; running the gevent path on default asyncio-based setups; slim Docker images without optional dependencies.","solutions":["Install gevent: `pip install gevent` (or `pip install 'polars[async]'` if the extra is offered)","Switch to gevent=False to use the default asyncio-based flow if gevent integration is not required","Add gevent to your requirements/lockfile so deployment images include it","Confirm the interpreter running the code is the one where gevent was installed"],"exampleFix":"// before\nout = lf.collect_async(gevent=True)  # ImportError: gevent is required\n// after\n# pip install gevent\nout = lf.collect_async(gevent=True)","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec('gevent') is None:\n    raise SystemExit(\"gevent required: pip install gevent\")","typeGuard":"def gevent_available() -> bool:\n    import importlib.util\n    return importlib.util.find_spec('gevent') is not None","tryCatchPattern":"try:\n    out = lf.collect_async(gevent=True)\nexcept ImportError:\n    out = lf.collect()  # or install gevent","preventionTips":["Add gevent to requirements whenever gevent=True flows are used","Use importlib.util.find_spec as a startup smoke check","Prefer asyncio (default) unless gevent integration is deliberate","Keep deployment images in sync with development requirements via a lockfile"],"tags":["python","async","gevent","optional-dependency"],"backgroundTag":"missing-optional-dependency","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}