diff --git a/python/python/lance/__init__.py b/python/python/lance/__init__.py index 83b22cf5215..54339c1291a 100644 --- a/python/python/lance/__init__.py +++ b/python/python/lance/__init__.py @@ -4,6 +4,8 @@ from __future__ import annotations import logging +import os +import warnings from typing import TYPE_CHECKING, Dict, Optional, Union from . import log @@ -153,3 +155,14 @@ def set_logger( log_handler=None, ): log.set_logger(file_path, name, level, format_string, log_handler) + + +def __warn_on_fork(): + warnings.warn( + "lance is not fork-safe. If you are using multiprocessing, " + "use spawn instead." + ) + + +if hasattr(os, "register_at_fork"): + os.register_at_fork(before=__warn_on_fork)