o
    tBh
                     @   s   d Z ddlZddlZddlmZ ddlmZ ddlmZ zddl	Z
			dd
dZW n ey9   			dddZY nw ejdkrMdZddlmZ dd ZdS ddlmZ dS )z,
Backports of fixes for joblib dependencies
    N)LooseVersion)basename)utiluint8r+CFc           	      C   sb   t d|t| t  tj| |||||d}ttj	dk r#||_
|r/ddlm} || |S )ab  Custom memmap constructor compatible with numpy.memmap.

        This function:
        - is a backport the numpy memmap offset fix (See
          https://github.com/numpy/numpy/pull/8443 for more details.
          The numpy fix is available starting numpy 1.13)
        - adds ``unlink_on_gc_collect``, which specifies  explicitly whether
          the process re-constructing the memmap owns a reference to the
          underlying file. If set to True, it adds a finalizer to the
          newly-created memmap that sends a maybe_unlink request for the
          memmaped file to resource_tracker.
        z?[MEMMAP READ] creating a memmap (shape {}, filename {}, pid {}))dtypemodeoffsetshapeorderz1.13   )add_maybe_unlink_finalizer)r   debugformatr   osgetpidnpmemmapr   __version__r
   _memmapping_reducerr   )	filenamer   r	   r
   r   r   unlink_on_gc_collectmmr    r   g/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/joblib/backports.pymake_memmap   s   r   c                 C   s   t d)NzL'joblib.backports.make_memmap' should not be used if numpy is not installed.)NotImplementedError)r   r   r	   r
   r   r   r   r   r   r   r   +   s   nt)      )replacec              
   C   s   d}d}d}||k r@zt | | W dS  ty; } zt|ddtv r0t| ||7 }|d9 }n W Y d}~nd}~ww ||k s
 )zRenames ``src`` into ``dst`` overwriting ``dst`` if it exists.

        On Windows os.replace can yield permission errors if executed by two
        different processes.
        r   r   gMbP?winerrorN   )r!   	Exceptiongetattraccess_denied_errorstimesleep)srcdstmax_sleep_timetotal_sleep_time
sleep_timeexcr   r   r   concurrency_safe_rename7   s$   


r/   )r   r   r   Nr   F)__doc__r   r'   distutils.versionr   os.pathr   multiprocessingr   numpyr   r   ImportErrornamer&   r!   r/   r   r   r   r   <module>   s*    
