fdZddlmZddlZddlZddlZddlZddlmZm Z m Z dZ ejjeZddZddZej$dk(reed d Zdd Zydd Zdd ZddZedk(rIeedr ej4eeej8ddej:dyy#e$rY6wxYw)zSupport for spawning a daemon process. PyMongo only attempts to spawn the mongocryptd daemon process when automatic client-side field level encryption is enabled. See :ref:`automatic-client-side-encryption` for more info. ) annotationsN)AnyOptionalSequence cZ |j|S#tj$rYywxYw)z,Implement wait timeout support for Python 3.)timeoutN)wait subprocessTimeoutExpired)popenr s W/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/pymongo/daemon.py _popen_waitr"s0zz'z**  $ $s **c|d|_yy)zpSilence Popen's ResourceWarning. Note this should only be used if the process was created as a daemon. Nr) returncode)r s r_silence_resource_warningr+s win32DETACHED_PROCESSc, ttjd5}tj|t |||}t |dddy#1swYyxYw#t$r/}tjd|dd|tdYd}~yd}~wwxYw) z!Spawn a daemon process (Windows).r+b) creationflagsstdinstderrstdoutNFailed to start r+: is it on your $PATH? Original exception:  stacklevel) openosdevnullr Popen_DETACHED_PROCESSrFileNotFoundErrorwarningswarnRuntimeWarning)argsr$r excs r _spawn_daemonr-=s bjj%( 1G"(("3!"" *%0 1 1 1!  MM"47)+WX[W\]   s4A*AAAAA B$%BBc ttjd5}tj|d|||cdddS#1swYyxYw#t $r/}t jd|dd|td Yd}~yd}~wwxYw) z,Spawn the process and silence stdout/stderr.rT) close_fdsrrrNrrrrr ) r"r#r$r r%r'r(r)r*)r+r$r,s r_spawnr0\s bjj%( G!''"!""     !  MM"47)+WX[W\]     s3A A A A A A B%A??Bctjtg}|j|t j |d}t |ty)z7Spawn a daemon process using a double subprocess.Popen.T)r/N)sys executable _THIS_FILEextendr r%r _WAIT_TIMEOUT)r+ spawner_args temp_procs r_spawn_daemon_double_popenr9os< 3 D!$$\TB  I}-rcRtjr t|yt|y)zSpawn a daemon process (Unix).N)r2r3r9r0)r+s rr-r-xs >> &t , 4Lr__main__setsid)r zsubprocess.Popen[Any]r zOptional[float]returnz Optional[int])r Optional[subprocess.Popen[Any]]r>None)r+ Sequence[str]r>r@)r+rAr>r?)__doc__ __future__rr#r r2r(typingrrrr6pathrealpath__file__r4rrplatformgetattrr&r-r0r9__name__hasattrr<OSErrorargv_exitrrrPs #  ** WW  h '  <<7 ,> K>&.": 2x   "&!""67    sCC C