"""Connector for Split.io SDK.""" from pythonfeatures import config from pythonfeatures.connectors.split_factory import get_split_factory factory = None try: # if you attempt to import uwsgi and receive an ImportError you’re not running under uWSGI. # Ref: https://uwsgi-docs.readthedocs.io/en/latest/PythonModule.html#the-uwsgi-python-module # If running under uwsgi, use preforked client setup # Ref: https://help.split.io/hc/en-us/articles/360020359652-Python-SDK#preforked-client-setup import uwsgi # noqa: F401 from uwsgidecorators import postfork factory = get_split_factory({ **config.SPLIT_CONFIG }) @postfork def post_fork_execution(): """Post fork execution.""" factory.resume() factory.block_until_ready(config.SPLIT_BLOCK_UNTIL_READY_TIMEOUT) except (ImportError, ModuleNotFoundError): factory = get_split_factory(config.SPLIT_CONFIG) if config.SPLIT_CONFIG.get('preforkedInitialization'): factory.resume() factory.block_until_ready(config.SPLIT_BLOCK_UNTIL_READY_TIMEOUT) split_client = factory.client() split_manager = factory.manager()