HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/billiard/__pycache__/context.cpython-310.pyc
o

!web3�@s�ddlZddlZddlZddlZddlmZgZdZddlm	Z	m
Z
mZmZm
Z
mZmZGdd�d�ZGdd	�d	ej�ZGd
d�de�Zedd
�ee�D��e_ejdkr�Gdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�de�ZGdd�de�ZGdd�de�Ze�e�e�d�Zeed�ZnGdd�dej�ZGdd�de�Zde�iZeed�Zd d!�Ze� �Z!d"d#�Z"d$d%�Z#d&d'�Z$dS)(�N�)�processzIforce_execv is not supported as the billiard C extension is not installed)�ProcessError�BufferTooShort�TimeoutError�AuthenticationError�TimeLimitExceeded�SoftTimeLimitExceeded�WorkerLostErrorc@sdeZdZeZeZeZeZeZeZe	Z	e
ej�Ze
ej
�Z
eed�r&dd�Zndd�Zdd�ZdEd	d
�Zdd�Zd
d�ZdFdd�ZdGdd�ZdGdd�Zdd�ZdHdd�ZdIdd�ZdIdd�Zd d!�Z	"					dJd#d$�Zd%d&�Zd'd(�Zd)d*�Z d+d,�Z!d-d.�Z"d/d0�Z#dFd1d2�Z$d3d4�Z%d5d6�Z&d7d8�Z'dFd9d:�Z(dKd;d<�Z)dFd=d>�Z*d?d@�Z+dAdB�Z,dCdD�Z-dS)L�BaseContext�	cpu_countcCst��}|durtd��|S)z(Returns the number of CPUs in the systemN�cannot determine number of cpus)�osr�NotImplementedError)�self�num�r�I/home/arjun/projects/env/lib/python3.10/site-packages/billiard/context.pyr2szBaseContext.cpu_countc
Cs�tjdkrz	ttjd�}Wnattfyd}YnUwdtjvs&tjdkrZd}tjdkr1d|}zt�|��}t|���}Wd�n1sHwYWn!tyYd}Ynwzt�	d�}Wntt
tfyod}Ynw|d	krv|Std
��)N�win32�NUMBER_OF_PROCESSORSr�bsd�darwinz/sbin/sysctl -n hw.ncpuz/usr�SC_NPROCESSORS_ONLNrr
)
�sys�platform�intr�environ�
ValueError�KeyError�popen�read�sysconf�OSError�AttributeErrorr)rr�comm�prrrr:s4
�
����cCs&ddlm}||��d�}|��|S)z�Returns a manager associated with a running server process

        The managers methods such as `Lock()`, `Condition()` and `Queue()`
        can be used to create shared objects.
        r)�SyncManager��ctx)�managersr&�get_context�start)rr&�mrrr�ManagerTszBaseContext.ManagerTFcCsddlm}||||�S)z1Returns two connection object connected by a piper)�Pipe)�
connectionr.)r�duplex�	rnonblock�	wnonblockr.rrrr._szBaseContext.PipecC�ddlm}||��d�S)z#Returns a non-recursive lock objectr)�Lockr')�synchronizer4r*)rr4rrrr4d�zBaseContext.LockcCr3)zReturns a recursive lock objectr)�RLockr')r5r7r*)rr7rrrr7ir6zBaseContext.RLockNcC�ddlm}|||��d�S)zReturns a condition objectr)�	Conditionr')r5r9r*)r�lockr9rrrr9n�zBaseContext.ConditionrcCr8)zReturns a semaphore objectr)�	Semaphorer')r5r<r*)r�valuer<rrrr<sr;zBaseContext.SemaphorecCr8)z"Returns a bounded semaphore objectr)�BoundedSemaphorer')r5r>r*)rr=r>rrrr>xr;zBaseContext.BoundedSemaphorecCr3)zReturns an event objectr)�Eventr')r5r?r*)rr?rrrr?}r6zBaseContext.EventcCs ddlm}|||||��d�S)zReturns a barrier objectr)�Barrierr')r5r@r*)r�parties�action�timeoutr@rrrr@�szBaseContext.BarrierrcCr8)�Returns a queue objectr)�Queuer')�queuesrEr*)r�maxsizerErrrrE�r;zBaseContext.QueuecCr8)rDr)�
JoinableQueuer')rFrHr*)rrGrHrrrrH�r;zBaseContext.JoinableQueuecCr3)rDr)�SimpleQueuer')rFrIr*)rrIrrrrI�r6zBaseContext.SimpleQueuercCs<ddlm}||||||||||	|
|||
|||||��d�S)zReturns a process pool objectr)�Pool)�context)�poolrJr*)r�	processes�initializer�initargs�maxtasksperchildrC�soft_timeout�lost_worker_timeout�max_restarts�max_restart_freq�
on_process_up�on_process_down�on_timeout_set�on_timeout_cancel�threads�	semaphore�putlocks�
allow_restartrJrrrrJ�s
�zBaseContext.PoolcGsddlm}||g|�R�S)zReturns a shared objectr)�RawValue)�sharedctypesr])r�typecode_or_type�argsr]rrrr]�r;zBaseContext.RawValuecCsddlm}|||�S)zReturns a shared arrayr)�RawArray)r^ra)rr_�size_or_initializerrarrrra�s
zBaseContext.RawArraycOs4ddlm}|�dd�}||g|�R||��d��S)z$Returns a synchronized shared objectr)�Valuer:T�r:r()r^rc�getr*)rr_r`�kwargsrcr:rrrrc�s
�zBaseContext.ValuecOs,ddlm}|�dd�}|||||��d�S)z#Returns a synchronized shared arrayr)�Arrayr:Trd)r^rgrer*)rr_rbr`rfrgr:rrrrg�s
�zBaseContext.ArraycCs4tjdkrttdd�rddlm}|�dSdSdS)z�Check whether this is a fake forked process in a frozen executable.
        If so then run code specified by commandline and exit.
        r�frozenFr)�freeze_supportN)rr�getattr�spawnri)rrirrrri�s
�zBaseContext.freeze_supportcCsddlm}|�S)zZReturn package logger -- if it does not already exist then
        it is created.
        r)�
get_logger)�utilrl)rrlrrrrl�szBaseContext.get_loggercCsddlm}||�S)z8Turn on logging and add a handler which prints to stderrr)�
log_to_stderr)rmrn)r�levelrnrrrrn��zBaseContext.log_to_stderrcCsddlm}dS)zVInstall support for sending connections and sockets
        between processes
        r)r/N)�r/)rr/rrr�allow_connection_pickling�sz%BaseContext.allow_connection_picklingcC�ddlm}||�dS)z�Sets the path to a python.exe or pythonw.exe binary used to run
        child processes instead of sys.executable when using the 'spawn'
        start method.  Useful for people embedding Python.
        r)�set_executableN)rkrt)r�
executablertrrrrt�szBaseContext.set_executablecCrs)zkSet list of module names to try to load in forkserver process.
        This is really just a hint.
        r)�set_forkserver_preloadN)�
forkserverrv)r�module_namesrvrrrrv�sz"BaseContext.set_forkserver_preloadcCs@|dur|Szt|}Wn
tytd|��w|��|S)Nzcannot find context for %r)�_concrete_contextsrr�_check_available)r�methodr(rrrr*�s�zBaseContext.get_contextcCs|jS�N)�_name�r�
allow_nonerrr�get_start_method�szBaseContext.get_start_methodcCstd��)Nz+cannot set start method of concrete context)r�rr{rrr�set_start_method�szBaseContext.set_start_methodcCs|��pddkS)N�fork)r��rrrr�forking_is_enabled��zBaseContext.forking_is_enabledcCs<|sddlm}|r|jddd�dSt�tt��dSdS)Nr)�
supports_execrkT)�force)�_extr�r��warnings�warn�RuntimeWarning�
W_NO_EXECV)rr=r�rrr�forking_enable�s�zBaseContext.forking_enablecCsdSr|rr�rrrrzszBaseContext._check_available)TFFr|)r)NN)r)NNrNNNNNrNNNNTNFF�F).�__name__�
__module__�__qualname__rrrrrr	r
�staticmethodr�current_process�active_children�hasattrrrr-r.r4r7r9r<r>r?r@rErHrIrJr]rarcrgrirlrnrrrtrvr*r�r�r�r�rzrrrrr$s`











�




	rc@seZdZdZedd��ZdS)�ProcessNcCst��j�|�Sr|)�_default_contextr*r��_Popen)�process_objrrrr�r�zProcess._Popen�r�r�r��
_start_methodr�r�rrrrr�
�r�csFeZdZeZdd�Zd
�fdd�	Zddd�Zdd	d
�Zdd�Z�Z	S)�DefaultContextcCs||_d|_dSr|)r��_actual_context)rrKrrr�__init__s
zDefaultContext.__init__Ncs0|dur|jdur
|j|_|jStt|��|�Sr|)r�r��superr�r*r���	__class__rrr*s

zDefaultContext.get_contextFcCs<|jdur|std��|dur|rd|_dS|�|�|_dS)Nzcontext has already been set)r��RuntimeErrorr*)rr{r�rrrr�$szDefaultContext.set_start_methodcCs"|jdur
|r	dS|j|_|jjSr|)r�r�r}r~rrrr�,s

zDefaultContext.get_start_methodcCs2tjdkrdgSddlm}|jrgd�SddgS)Nrrkr��	reduction�r�rkrwr�)rrrqr��HAVE_SEND_HANDLE�rr�rrr�get_all_start_methods3s
z$DefaultContext.get_all_start_methodsr|r�)
r�r�r�r�r�r*r�r�r��
__classcell__rrr�rr�s

r�ccs �|]}|ddkr|VqdS)r�_Nr)�.0�xrrr�	<genexpr>=s�r�rc@�eZdZdZedd��ZdS)�ForkProcessr�cC�ddlm}||�S�Nr)�Popen)�
popen_forkr��r�r�rrrr�HrpzForkProcess._PopenNr�rrrrr�Er�r�c@r�)�SpawnProcessrkcCr�r�)�popen_spawn_posixr�r�rrrr�Prp�SpawnProcess._PopenNr�rrrrr�Mr�r�c@r�)�ForkServerProcessrwcCr�r�)�popen_forkserverr�r�rrrr�XrpzForkServerProcess._PopenNr�rrrrr�Ur�r�c@�eZdZdZeZdS)�ForkContextr�N)r�r�r�r}r�r�rrrrr�]�r�c@r���SpawnContextrkN�r�r�r�r}r�r�rrrrr�ar�r�c@seZdZdZeZdd�ZdS)�ForkServerContextrwcCsddlm}|js
td��dS)Nrr�z%forkserver start method not available)rqr�r�rr�rrrrzis�z"ForkServerContext._check_availableN)r�r�r�r}r�r�rzrrrrr�esr�r�r�c@r�)r�rkcCr�r�)�popen_spawn_win32r�r�rrrr�zrpr�Nr�rrrrr�wr�c@r�r�r�rrrrr�r�rkcCst|t_dSr|)ryr�r�)r{rrr�_force_start_method�sr�cCsttdd�S)N�spawning_popen)rj�_tlsrrrr�get_spawning_popen�sr�cCs
|t_dSr|)r�r�)rrrr�set_spawning_popen�s
r�cCs t�durtdt|�j��dS)NzF%s objects should only be shared between processes through inheritance)r�r��typer�)�objrrr�assert_spawning�s
���r�)%rr�	threadingr�rqr�__all__r��
exceptionsrrrrrr	r
r�BaseProcessr�r��list�dirrr�r�r�r�r�r�ryr�r��localr�r�r�r�rrrr�<module>sF$
j(

��