o
    3g                     @  sX   U d Z ddlmZ ddlZddlmZ ddlmZ eee Z	e	a
ded< dd	d
ZdS )a  
EXPERIMENTAL! use with caution
Manages 'global' ProcessPoolExecutor which is 'managed' by HPI itself, and
can be passed down to DALs to speed up data processing.

The reason to have it managed by HPI is because we don't want DALs instantiate pools
themselves -- they can't cooperate and it would be hard/infeasible to control
how many cores we want to dedicate to the DAL.

Enabled by the env variable, specifying how many cores to dedicate
e.g. "HPI_CPU_POOL=4 hpi query ..."
    )annotationsN)ProcessPoolExecutor)castProcessPoolExecutor | None	_INSTANCEreturnc                  C  sB   t tu rtjd} | d u st| dkrd a t S tt| da t S )NHPI_CPU_POOLr   )max_workers)r   _NOT_SETosenvirongetintr   )use_cpu_pool r   +/home/garg/my-data/HPI/my/core/_cpu_pool.pyget_cpu_pool   s   r   )r   r   )__doc__
__future__r   r   concurrent.futuresr   typingr   objectr
   r   __annotations__r   r   r   r   r   <module>   s    