
    vKg                       % S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKJr  S SKJ	r	  S SK
JrJrJrJrJrJr  S SKrSSKJrJr  SSKJr  SS	KJrJrJr  SS
KJr  SSKJrJr  \(       a$  S SK r S SK!J"r"J#r#J$r$J%r%  S SK&J'r'  S SK(J)r)  SSK*J+r+J,r,  \RZ                  S:  a)  \\.\/\R`                  \.   \R`                  \/   4   r1S\2S'   O\\.\/SS4   r1S\2S'   S\2S'   \(       a  S<S jr3SSKJ4r4J5r5  O	Sr6 S SKJ3r3   " S  S!\5      rA\ " S" S#\S$95       rBSSSS%.           S=S& jjrCS>S' jrDS>S( jrES)SSSS\R                  S*.                 S?S+ jjrG\(       Gak  \Rp                  S,:X  af  SSSSSSSSS S-.	                     S@S. jjrH\R                  SSSSSSSSSSSSS S/.                               SAS0 jjrIg\SSSSSSSSSS1S2.
                         SBS3 jj5       rH\SSSSSSSSSSS1S4.                         SCS5 jj5       rH\\R                  SSSSSSSSSSSSSS1S6.                                   SDS7 jj5       rI\\R                  SSSSSSSSSSSSSSS1S8.                                   SES9 jj5       rIg\CrHS:=\HlJ        \HlK        \GrIS;=\IlJ        \IlK        g! \7 a    \Rp                  S:X  al  S SK9r9\9Rt                  " SSS9r;\9Rx                  \;Rz                  l>        \9Rx                  \9Rx                  \9Rx                  /\;Rz                  l?        Sr@S<S jr3 GNxSr6 GN}f = f)F    )annotationsN)	ExitStack)partial)TYPE_CHECKINGFinalLiteralProtocolUnionoverload   )ClosedResourceError
TaskStatus)StapledStream)create_pipe_from_child_outputcreate_pipe_to_child_stdinwait_child_exiting)Lock)NoPublicConstructorfinal)	AwaitableCallableMappingSequence)TextIOWrapper)	TypeAlias)ReceiveStream
SendStream)   	   r   StrOrBytesPathzos.PathLike[str]zos.PathLike[bytes]boolcan_try_pidfd_openc                    g N )fdflagss     P/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/trio/_subprocess.py
pidfd_openr)   3   s        )ClosableReceiveStreamClosableSendStreamT)r)   linux)	use_errnoi  c                    [         R                  [        X5      nUS:  a5  [        R                  " 5       n[        U[        R                  " U5      5      eU$ Nr   )_cdll_for_pidfd_opensyscall__NR_pidfd_openctypes	get_errnoOSErrorosstrerror)r&   r'   resulterrs       r(   r)   r)   W   sD    -55orQA: **,C!#r{{3'788r*   Fc                  "    \ rS rSrSrSS jrSrg)	HasFilenob   z;Represents any file-like object that has a file descriptor.c                    g r$   r%   selfs    r(   filenoHasFileno.filenoe   s    Sr*   r%   Nreturnint)__name__
__module____qualname____firstlineno____doc__rA   __static_attributes__r%   r*   r(   r<   r<   b   s    E r*   r<   c                      \ rS rSr% SrSrS\S'   SrS\S'   SrS\S'   Sr	S	\S
'             SS jr
SS jr\SS j5       rSS jrSS jrSS jrSS jrSS jrSS jrSrg)Processh   u"  A child process. Like :class:`subprocess.Popen`, but async.

This class has no public constructor. The most common way to get a
`Process` object is to combine `Nursery.start` with `run_process`::

   process_object = await nursery.start(run_process, ...)

This way, `run_process` supervises the process and makes sure that it is
cleaned up properly, while optionally checking the return value, feeding
it input, and so on.

If you need more control – for example, because you want to spawn a child
process that outlives your program – then another option is to use
`trio.lowlevel.open_process`::

   process_object = await trio.lowlevel.open_process(...)

Attributes:
  args (str or list): The ``command`` passed at construction time,
      specifying the process to execute and its arguments.
  pid (int): The process ID of the child process managed by this object.
  stdin (trio.abc.SendStream or None): A stream connected to the child's
      standard input stream: when you write bytes here, they become available
      for the child to read. Only available if the :class:`Process`
      was constructed using ``stdin=PIPE``; otherwise this will be None.
  stdout (trio.abc.ReceiveStream or None): A stream connected to
      the child's standard output stream: when the child writes to
      standard output, the written bytes become available for you
      to read here. Only available if the :class:`Process` was
      constructed using ``stdout=PIPE``; otherwise this will be None.
  stderr (trio.abc.ReceiveStream or None): A stream connected to
      the child's standard error stream: when the child writes to
      standard error, the written bytes become available for you
      to read here. Only available if the :class:`Process` was
      constructed using ``stderr=PIPE``; otherwise this will be None.
  stdio (trio.StapledStream or None): A stream that sends data to
      the child's standard input and receives from the child's standard
      output. Only available if both :attr:`stdin` and :attr:`stdout` are
      available; otherwise this will be None.

Fr   universal_newlinesNencodingerrorsobject_wait_for_exit_datac                   Xl         X l        X0l        X@l        S U l        U R                  b2  U R                  b%  [        U R                  U R                  5      U l        [        5       U l        S U l        [        (       a1   [        U R                   R                  S5      n[        U5      U l        U R                   R                  U l        U R                   R                  U l        g ! [         a     NCf = fr0   )_procstdinstdoutstderrstdior   r   
_wait_lock_pidfdr"   r)   pidopenr6   args)r@   popenrV   rW   rX   r&   s         r(   __init__Process.__init__   s     

FJ
::!dkk&=&tzz4;;?DJ $,0'$TZZ^^Q7 #2h?Czz	

  
 s    C( (
C54C5c                    U R                   nUc  SU R                   3nOUS:  a  SU*  3nOSU 3nSU R                  < SU S3$ )Nzrunning with PID r   zexited with signal zexited with status z<trio.Process z: >)
returncoder\   r^   )r@   rd   statuss      r(   __repr__Process.__repr__   s[    __
(
3FA~.
{m<.zl;		}Bvha88r*   c                `    U R                   R                  5       nUb  U R                  5         U$ )a?  The exit status of the process (an integer), or ``None`` if it's
still running.

By convention, a return code of zero indicates success.  On
UNIX, negative values indicate termination due to a signal,
e.g., -11 if terminated by signal 11 (``SIGSEGV``).  On
Windows, a process that exits due to a call to
:meth:`Process.terminate` will have an exit status of 1.

Unlike the standard library `subprocess.Popen.returncode`, you don't
have to call `poll` or `wait` to update this attribute; it's
automatically updated as needed, and will always give you the latest
information.

)rU   poll_close_pidfd)r@   r9   s     r(   rd   Process.returncode   s+    " "r*   c                    U R                   bY  [        R                  R                  U R                   R	                  5       5        U R                   R                  5         S U l         g g r$   )r[   triolowlevelnotify_closingrA   closer?   s    r(   rj   Process._close_pidfd   sG    ;;"MM((););)=>KKDK #r*   c                  #    U R                    ISh  vN   U R                  5       c  U R                  bc  [        R                  " [
        5         [        R                  R                  U R                  R                  5       5      I Sh  vN   SSS5        O[        U 5      I Sh  vN   U R                  R                  5         U R                  5         SSS5      ISh  vN   U R                  R                  c   eU R                  R                  $  GN N! , (       d  f       N|= f N NK! , ISh  vN  (       d  f       N`= f7f)zcBlock until the process exits.

Returns:
  The exit status of the process; see :attr:`returncode`.
N)rZ   ri   r[   
contextlibsuppressr   rm   rn   wait_readablerA   r   rU   waitrj   rd   r?   s    r(   rv   Process.wait   s      ???yy{";;*#,,+ #mm99$++:L:L:NOOO 
 -T222 

!!!#! #?" zz$$000zz$$$% # P 
 3 #???sz   E	DE	9D/;DDDD/'D+(.D/E	!D-"4E	D
D(	$D/-E	/E5D86EE	c                    U R                   $ )a[  Returns the exit status of the process (an integer), or ``None`` if
it's still running.

Note that on Trio (unlike the standard library `subprocess.Popen`),
``process.poll()`` and ``process.returncode`` always give the same
result. See `returncode` for more details. This method is only
included to make it easier to port code from `subprocess`.

)rd   r?   s    r(   ri   Process.poll  s     r*   c                :    U R                   R                  U5        g)a  Send signal ``sig`` to the process.

On UNIX, ``sig`` may be any signal defined in the
:mod:`signal` module, such as ``signal.SIGINT`` or
``signal.SIGTERM``. On Windows, it may be anything accepted by
the standard library :meth:`subprocess.Popen.send_signal`.
N)rU   send_signal)r@   sigs     r(   r{   Process.send_signal  s     	

s#r*   c                8    U R                   R                  5         g)a6  Terminate the process, politely if possible.

On UNIX, this is equivalent to
``send_signal(signal.SIGTERM)``; by convention this requests
graceful termination, but a misbehaving or buggy process might
ignore it. On Windows, :meth:`terminate` forcibly terminates the
process in the same manner as :meth:`kill`.
N)rU   	terminater?   s    r(   r   Process.terminate  s     	

r*   c                8    U R                   R                  5         g)aa  Immediately terminate the process.

On UNIX, this is equivalent to
``send_signal(signal.SIGKILL)``.  On Windows, it calls
``TerminateProcess``. In both cases, the process cannot
prevent itself from being killed, but the termination will be
delivered asynchronously; use :meth:`wait` if you want to
ensure the process is actually dead before proceeding.
N)rU   killr?   s    r(   r   Process.kill%  s     	

r*   )	r[   rU   rZ   r^   r\   rX   rV   rY   rW   )
r_   zsubprocess.Popen[bytes]rV   zSendStream | NonerW   ReceiveStream | NonerX   r   rD   None)rD   str)rD   z
int | NonerD   r   rC   )r|   zsignal.Signals | intrD   r   )rF   rG   rH   rI   rJ   rO   __annotations__rP   rQ   rS   r`   rf   propertyrd   rj   rv   ri   r{   r   r   rK   r%   r*   r(   rM   rM   h   s    (V !&%HeFE
 #'&#'&#' !#' %	#'
 %#' 
#'J	9  *%4
$	
r*   rM   )	metaclassrV   rW   rX   c               J  #    S H(  nUR                  U5      (       d  M  [        SU S35      e   [        R                  S:X  ax  [	        U [
        [        45      (       a!  UR                  S5      (       d  [        S5      e[	        U [
        [        45      (       d!  UR                  S5      (       a  [        S5      eSnSnSn[        5        n	[        5        n
U[        R                  :X  aG  [        5       u  paU	R                  [        R                  U5        U
R                  UR                  5        U[        R                  :X  aG  [        5       u  prU	R                  [        R                  U5        U
R                  UR                  5        U[        R                  :X  a  Ub  UnO[U[        R                  :X  aG  [        5       u  pU	R                  [        R                  U5        U
R                  UR                  5        [        R                   R#                  [%        [        R&                  U 4UUUS	.UD65      I Sh  vN nU
R)                  5         SSS5        SSS5        [*        R-                  WXgU5      $  N;! , (       d  f       N/= f! , (       d  f       N8= f7f)
a	  Execute a child program in a new process.

After construction, you can interact with the child process by writing data to its
`~trio.Process.stdin` stream (a `~trio.abc.SendStream`), reading data from its
`~trio.Process.stdout` and/or `~trio.Process.stderr` streams (both
`~trio.abc.ReceiveStream`\s), sending it signals using `~trio.Process.terminate`,
`~trio.Process.kill`, or `~trio.Process.send_signal`, and waiting for it to exit
using `~trio.Process.wait`. See `trio.Process` for details.

Each standard stream is only available if you specify that a pipe should be created
for it. For example, if you pass ``stdin=subprocess.PIPE``, you can write to the
`~trio.Process.stdin` stream, else `~trio.Process.stdin` will be ``None``.

Unlike `trio.run_process`, this function doesn't do any kind of automatic
management of the child process. It's up to you to implement whatever semantics you
want.

Args:
  command: The command to run. Typically this is a sequence of strings or
      bytes such as ``['ls', '-l', 'directory with spaces']``, where the
      first element names the executable to invoke and the other elements
      specify its arguments. With ``shell=True`` in the ``**options``, or on
      Windows, ``command`` can be a string or bytes, which will be parsed
      following platform-dependent :ref:`quoting rules
      <subprocess-quoting>`. In all cases ``command`` can be a path or a
      sequence of paths.
  stdin: Specifies what the child process's standard input
      stream should connect to: output written by the parent
      (``subprocess.PIPE``), nothing (``subprocess.DEVNULL``),
      or an open file (pass a file descriptor or something whose
      ``fileno`` method returns one). If ``stdin`` is unspecified,
      the child process will have the same standard input stream
      as its parent.
  stdout: Like ``stdin``, but for the child process's standard output
      stream.
  stderr: Like ``stdin``, but for the child process's standard error
      stream. An additional value ``subprocess.STDOUT`` is supported,
      which causes the child's standard output and standard error
      messages to be intermixed on a single standard output stream,
      attached to whatever the ``stdout`` option says to attach it to.
  **options: Other :ref:`general subprocess options <subprocess-options>`
      are also accepted.

Returns:
  A new `trio.Process` object.

Raises:
  OSError: if the process spawning fails, for example because the
     specified command could not be found.

)rO   textrP   rQ   bufsizezLtrio.Process only supports communicating over unbuffered byte streams; the 'z' option is not supportedposixshellzQcommand must be a sequence (not a string or bytes) if shell=False on UNIX systemszPcommand must be a string or bytes (not a sequence) if shell=True on UNIX systemsNr   )get	TypeErrorr7   name
isinstancer   bytesr   
subprocessPIPEr   callbackrp   r   STDOUTrm   	to_threadrun_syncr   Popenpop_allrM   _create)commandrV   rW   rX   optionskey
trio_stdintrio_stdouttrio_stderralways_cleanupcleanup_on_failr_   s               r(   _open_processr   2  s2    v O;;s1145NP  O 
ww'gU|,,W[[5I5I.  'C<00W[[5I5I- 
 -1J04K04K 
	JOO# : <J##BHHe4$$Z%5%56Z__$"?"AK##BHHf5$$[%6%67Z&&& !z&"?"AK##BHHf5$$[%6%67nn--    	
 	
 	!G )4J ??5*;GG	
1 )4sN   J#B-J#JE+JI?JJ J#?J
J	J
J J#c           	        #     U R                  5         g ! [         a0  n[        R                  " [	        SU < SU< 35      SS9   S nAg S nAff = f7f)NzTerminateProcess on z failed with: r   
stacklevel)r   r6   warningswarnRuntimeWarningpexcs     r(   _windows_deliver_cancelr     sG     
	 
1!nSGLM	

s*   A A
A&A
A
AAc           	     N  #     U R                  5         [        R                  " S5      I S h  vN   [        R                  " [        SU < S35      SS9  U R                  5         g  N8! [         a0  n[        R                  " [        SU < SU< 35      SS9   S nAg S nAff = f7f)N   zprocess z` ignored SIGTERM for 5 seconds. (Maybe you should pass a custom deliver_cancel?) Trying SIGKILL.r   r   ztried to kill process z, but failed with: )r   rm   sleepr   r   r   r   r6   r   s     r(   _posix_deliver_cancelr     s     
	jjm1%  " "
 	
 	
 	  
3A58KC7ST	

s>   B%)A( A&7A( %B%&A( (
B"2&BB%B""B%r*   )rV   capture_stdoutcapture_stderrcheckdeliver_canceltask_statusc               B  ^^^^#    [        U[        5      (       a  [        S5      eU[        R                  L ax  U[
        R                  L a  [        S5      eUR                  S5      [
        R                  L a  [        S5      eUR                  S5      [
        R                  L a  [        S5      e[        U[        [        [        45      (       a  Um[
        R                  US'   OSmXS'   U(       a$  SU;   a  [        S	5      e[
        R                  US'   U(       a$  SU;   a  [        S
5      e[
        R                  US'   Tc7  [        R                  S:X  a  [        mO[        R                  S:X  d   e[        m/ n/ n	SU4S jjn
      SS jn[!        U 40 UD6I Sh  vN m[        R"                  " 5        ISh  vN n Tb9  TR$                  c   eUR'                  U
TR$                  5        STl        STl        U(       a:  TR*                  c   eUR'                  UTR*                  U5        STl        STl        U(       a3  TR,                  c   eUR'                  UTR,                  U	5        STl        UR/                  T5        TR1                  5       I Sh  vN   SSS5      ISh  vN   U(       a  SR9                  U5      OSnU(       a  SR9                  U	5      OSnTR:                  (       a2  U(       a+  [
        R<                  " TR:                  TR>                  UUS9eTR:                  c   e[
        R@                  " TR>                  TR:                  X5      $  GN GN N! [2         a    [        R4                  " SS9   [        R4                  " SS9mSUUU4S jjnUR'                  U5        TR1                  5       I Sh  vN    TR7                  5         e ! , (       d  f        GNR= ff = f GNN! , ISh  vN  (       d  f       GNd= f7f)u$  Run ``command`` in a subprocess and wait for it to complete.

This function can be called in two different ways.

One option is a direct call, like::

    completed_process_info = await trio.run_process(...)

In this case, it returns a :class:`subprocess.CompletedProcess` instance
describing the results. Use this if you want to treat a process like a
function call.

The other option is to run it as a task using `Nursery.start` – the enhanced version
of `~Nursery.start_soon` that lets a task pass back a value during startup::

    process = await nursery.start(trio.run_process, ...)

In this case, `~Nursery.start` returns a `Process` object that you can use
to interact with the process while it's running. Use this if you want to
treat a process like a background task.

Either way, `run_process` makes sure that the process has exited before
returning, handles cancellation, optionally checks for errors, and
provides some convenient shorthands for dealing with the child's
input/output.

**Input:** `run_process` supports all the same ``stdin=`` arguments as
`subprocess.Popen`. In addition, if you simply want to pass in some fixed
data, you can pass a plain `bytes` object, and `run_process` will take
care of setting up a pipe, feeding in the data you gave, and then sending
end-of-file. The default is ``b""``, which means that the child will receive
an empty stdin. If you want the child to instead read from the parent's
stdin, use ``stdin=None``.

**Output:** By default, any output produced by the subprocess is
passed through to the standard output and error streams of the
parent Trio process.

When calling `run_process` directly, you can capture the subprocess's output by
passing ``capture_stdout=True`` to capture the subprocess's standard output, and/or
``capture_stderr=True`` to capture its standard error. Captured data is collected up
by Trio into an in-memory buffer, and then provided as the
:attr:`~subprocess.CompletedProcess.stdout` and/or
:attr:`~subprocess.CompletedProcess.stderr` attributes of the returned
:class:`~subprocess.CompletedProcess` object. The value for any stream that was not
captured will be ``None``.

If you want to capture both stdout and stderr while keeping them
separate, pass ``capture_stdout=True, capture_stderr=True``.

If you want to capture both stdout and stderr but mixed together
in the order they were printed, use: ``capture_stdout=True, stderr=subprocess.STDOUT``.
This directs the child's stderr into its stdout, so the combined
output will be available in the `~subprocess.CompletedProcess.stdout`
attribute.

If you're using ``await nursery.start(trio.run_process, ...)`` and want to capture
the subprocess's output for further processing, then use ``stdout=subprocess.PIPE``
and then make sure to read the data out of the `Process.stdout` stream. If you want
to capture stderr separately, use ``stderr=subprocess.PIPE``. If you want to capture
both, but mixed together in the correct order, use ``stdout=subprocess.PIPE,
stderr=subprocess.STDOUT``.

**Error checking:** If the subprocess exits with a nonzero status
code, indicating failure, :func:`run_process` raises a
:exc:`subprocess.CalledProcessError` exception rather than
returning normally. The captured outputs are still available as
the :attr:`~subprocess.CalledProcessError.stdout` and
:attr:`~subprocess.CalledProcessError.stderr` attributes of that
exception.  To disable this behavior, so that :func:`run_process`
returns normally even if the subprocess exits abnormally, pass ``check=False``.

Note that this can make the ``capture_stdout`` and ``capture_stderr``
arguments useful even when starting `run_process` as a task: if you only
care about the output if the process fails, then you can enable capturing
and then read the output off of the `~subprocess.CalledProcessError`.

**Cancellation:** If cancelled, `run_process` sends a termination
request to the subprocess, then waits for it to fully exit. The
``deliver_cancel`` argument lets you control how the process is terminated.

.. note:: `run_process` is intentionally similar to the standard library
   `subprocess.run`, but some of the defaults are different. Specifically, we
   default to:

   - ``check=True``, because `"errors should never pass silently / unless
     explicitly silenced" <https://www.python.org/dev/peps/pep-0020/>`__.

   - ``stdin=b""``, because it produces less-confusing results if a subprocess
     unexpectedly tries to read from stdin.

   To get the `subprocess.run` semantics, use ``check=False, stdin=None``.

Args:
  command (list or str): The command to run. Typically this is a
      sequence of strings such as ``['ls', '-l', 'directory with spaces']``,
      where the first element names the executable to invoke and the other
      elements specify its arguments. With ``shell=True`` in the
      ``**options``, or on Windows, ``command`` may alternatively
      be a string, which will be parsed following platform-dependent
      :ref:`quoting rules <subprocess-quoting>`.

  stdin (:obj:`bytes`, subprocess.PIPE, file descriptor, or None): The
      bytes to provide to the subprocess on its standard input stream, or
      ``None`` if the subprocess's standard input should come from the
      same place as the parent Trio process's standard input. As is the
      case with the :mod:`subprocess` module, you can also pass a file
      descriptor or an object with a ``fileno()`` method, in which case
      the subprocess's standard input will come from that file.

      When starting `run_process` as a background task, you can also use
      ``stdin=subprocess.PIPE``, in which case `Process.stdin` will be a
      `~trio.abc.SendStream` that you can use to send data to the child.

  capture_stdout (bool): If true, capture the bytes that the subprocess
      writes to its standard output stream and return them in the
      `~subprocess.CompletedProcess.stdout` attribute of the returned
      `subprocess.CompletedProcess` or `subprocess.CalledProcessError`.

  capture_stderr (bool): If true, capture the bytes that the subprocess
      writes to its standard error stream and return them in the
      `~subprocess.CompletedProcess.stderr` attribute of the returned
      `~subprocess.CompletedProcess` or `subprocess.CalledProcessError`.

  check (bool): If false, don't validate that the subprocess exits
      successfully. You should be sure to check the
      ``returncode`` attribute of the returned object if you pass
      ``check=False``, so that errors don't pass silently.

  deliver_cancel (async function or None): If `run_process` is cancelled,
      then it needs to kill the child process. There are multiple ways to
      do this, so we let you customize it.

      If you pass None (the default), then the behavior depends on the
      platform:

      - On Windows, Trio calls ``TerminateProcess``, which should kill the
        process immediately.

      - On Unix-likes, the default behavior is to send a ``SIGTERM``, wait
        5 seconds, and send a ``SIGKILL``.

      Alternatively, you can customize this behavior by passing in an
      arbitrary async function, which will be called with the `Process`
      object as an argument. For example, the default Unix behavior could
      be implemented like this::

         async def my_deliver_cancel(process):
             process.send_signal(signal.SIGTERM)
             await trio.sleep(5)
             process.send_signal(signal.SIGKILL)

      When the process actually exits, the ``deliver_cancel`` function
      will automatically be cancelled – so if the process exits after
      ``SIGTERM``, then we'll never reach the ``SIGKILL``.

      In any case, `run_process` will always wait for the child process to
      exit before raising `Cancelled`.

  **options: :func:`run_process` also accepts any :ref:`general subprocess
      options <subprocess-options>` and passes them on to the
      :class:`~trio.Process` constructor. This includes the
      ``stdout`` and ``stderr`` options, which provide additional
      redirection possibilities such as ``stderr=subprocess.STDOUT``,
      ``stdout=subprocess.DEVNULL``, or file descriptors.

Returns:

  When called normally – a `subprocess.CompletedProcess` instance
  describing the return code and outputs.

  When called via `Nursery.start` – a `trio.Process` instance.

Raises:
  UnicodeError: if ``stdin`` is specified as a Unicode string, rather
      than bytes
  ValueError: if multiple redirections are specified for the same
      stream, e.g., both ``capture_stdout=True`` and
      ``stdout=subprocess.DEVNULL``
  subprocess.CalledProcessError: if ``check=False`` is not passed
      and the process exits with a nonzero exit status
  OSError: if an error is encountered starting or communicating with
      the process
  ExceptionGroup: if exceptions occur in ``deliver_cancel``,
      or when exceptions occur when communicating with the subprocess.
      If strict_exception_groups is set to false in the global context,
      which is deprecated, then single exceptions will be collapsed.

.. note:: The child process runs in the same process group as the parent
   Trio process, so a Ctrl+C will be delivered simultaneously to both
   parent and child. If you don't want this behavior, consult your
   platform's documentation for starting child processes in a different
   process group.

z$process stdin must be bytes, not strzstdout=subprocess.PIPE is only valid with nursery.start, since that's the only way to access the pipe; use nursery.start or pass the data you want to write directlyrW   zestdout=subprocess.PIPE is only valid with nursery.start, since that's the only way to access the piperX   zestderr=subprocess.PIPE is only valid with nursery.start, since that's the only way to access the piperV   Nz,can't specify both stdout and capture_stdoutz,can't specify both stderr and capture_stderrntr   c                   >#    U  IS h  vN    Tc   eU R                  T5      I S h  vN   S S S 5      IS h  vN   g  N4 N! [        R                   a     N+f = f N#! , IS h  vN  (       d  f       g = f7fr$   )send_allrm   BrokenResourceError)streaminput_s    r(   
feed_input _run_process.<locals>.feed_input  s_     6)))oof--- 66 .++ 	 666sm   A9?A9AAAAA9AA9AAAAAA9A6%A(&A62A9c                   #    U  IS h  vN   U   S h  vN nUR                  U5        M   N" N
 S S S 5      IS h  vN    g ! , IS h  vN  (       d  f       g = f7fr$   )append)r   chunkschunks      r(   read_output!_run_process.<locals>.read_output  s=      6% %ee$ %v 66666sX   A,AA0.0AA0AA?AA	A
AAT)shieldc                 j   >#    T   T " T5      I S h  vN   S S S 5        g  N! , (       d  f       g = f7fr$   r%   )r   killer_cscopeprocs   r(   killer_run_process.<locals>.killer  s(     &,T222 '2 's    3" "	3"
03r*   )outputrX   )r   r   rD   r   )r   r   r   zlist[bytes | bytearray]rD   r   r   )!r   r   UnicodeErrorrm   TASK_STATUS_IGNOREDr   r   
ValueErrorr   r   	bytearray
memoryviewr7   r   r   r   open_processopen_nurseryrV   
start_soonrY   rW   rX   startedrv   BaseExceptionCancelScopecanceljoinrd   CalledProcessErrorr^   CompletedProcess)r   rV   r   r   r   r   r   r   stdout_chunksstderr_chunksr   r   nurseryr   rW   rX   r   r   r   s        `          @@@r(   _run_processr     sz    ^ %ABBd...JOO#> 
 ;;x JOO3?  ;;x JOO3?  %%J788%??
  wKLL&OOwKLL&OO77d?4N77g%%%2N-/M-/M%%'% 
% g111D  ""g	!zz---"":tzz:!
!
{{..."";]K"!
{{..."";]K"%))+# #"> )7SXXm$DF(6SXXm$DF5++OOII	
 	
 *****499doovVVY 2""  	!!. $ 0 0 =3 3 ""6*iik!!$$& /.	% #"""s   FP$M*%PM-PPCM2#M0$M2(P3P4B7P-P0M22O>AO*O
O**
O:4O>7P:O>>PPP
PPPwin32)	rV   rW   rX   	close_fdsr   cwdenvstartupinfocreationflagsc       	           #    g7f)a	  Execute a child program in a new process.

After construction, you can interact with the child process by writing data to its
`~trio.Process.stdin` stream (a `~trio.abc.SendStream`), reading data from its
`~trio.Process.stdout` and/or `~trio.Process.stderr` streams (both
`~trio.abc.ReceiveStream`\s), sending it signals using `~trio.Process.terminate`,
`~trio.Process.kill`, or `~trio.Process.send_signal`, and waiting for it to exit
using `~trio.Process.wait`. See `trio.Process` for details.

Each standard stream is only available if you specify that a pipe should be created
for it. For example, if you pass ``stdin=subprocess.PIPE``, you can write to the
`~trio.Process.stdin` stream, else `~trio.Process.stdin` will be ``None``.

Unlike `trio.run_process`, this function doesn't do any kind of automatic
management of the child process. It's up to you to implement whatever semantics you
want.

Args:
  command (list or str): The command to run. Typically this is a
      sequence of strings such as ``['ls', '-l', 'directory with spaces']``,
      where the first element names the executable to invoke and the other
      elements specify its arguments. With ``shell=True`` in the
      ``**options``, or on Windows, ``command`` may alternatively
      be a string, which will be parsed following platform-dependent
      :ref:`quoting rules <subprocess-quoting>`.
  stdin: Specifies what the child process's standard input
      stream should connect to: output written by the parent
      (``subprocess.PIPE``), nothing (``subprocess.DEVNULL``),
      or an open file (pass a file descriptor or something whose
      ``fileno`` method returns one). If ``stdin`` is unspecified,
      the child process will have the same standard input stream
      as its parent.
  stdout: Like ``stdin``, but for the child process's standard output
      stream.
  stderr: Like ``stdin``, but for the child process's standard error
      stream. An additional value ``subprocess.STDOUT`` is supported,
      which causes the child's standard output and standard error
      messages to be intermixed on a single standard output stream,
      attached to whatever the ``stdout`` option says to attach it to.
  **options: Other :ref:`general subprocess options <subprocess-options>`
      are also accepted.

Returns:
  A new `trio.Process` object.

Raises:
  OSError: if the process spawning fails, for example because the
     specified command could not be found.

Nr%   )
r   rV   rW   rX   r   r   r   r   r   r   s
             r(   r   r      s     ~    )r   rV   r   r   r   r   rW   rX   r   r   r   r   r   r   c                  #    g7f)u#  Run ``command`` in a subprocess and wait for it to complete.

This function can be called in two different ways.

One option is a direct call, like::

    completed_process_info = await trio.run_process(...)

In this case, it returns a :class:`subprocess.CompletedProcess` instance
describing the results. Use this if you want to treat a process like a
function call.

The other option is to run it as a task using `Nursery.start` – the enhanced version
of `~Nursery.start_soon` that lets a task pass back a value during startup::

    process = await nursery.start(trio.run_process, ...)

In this case, `~Nursery.start` returns a `Process` object that you can use
to interact with the process while it's running. Use this if you want to
treat a process like a background task.

Either way, `run_process` makes sure that the process has exited before
returning, handles cancellation, optionally checks for errors, and
provides some convenient shorthands for dealing with the child's
input/output.

**Input:** `run_process` supports all the same ``stdin=`` arguments as
`subprocess.Popen`. In addition, if you simply want to pass in some fixed
data, you can pass a plain `bytes` object, and `run_process` will take
care of setting up a pipe, feeding in the data you gave, and then sending
end-of-file. The default is ``b""``, which means that the child will receive
an empty stdin. If you want the child to instead read from the parent's
stdin, use ``stdin=None``.

**Output:** By default, any output produced by the subprocess is
passed through to the standard output and error streams of the
parent Trio process.

When calling `run_process` directly, you can capture the subprocess's output by
passing ``capture_stdout=True`` to capture the subprocess's standard output, and/or
``capture_stderr=True`` to capture its standard error. Captured data is collected up
by Trio into an in-memory buffer, and then provided as the
:attr:`~subprocess.CompletedProcess.stdout` and/or
:attr:`~subprocess.CompletedProcess.stderr` attributes of the returned
:class:`~subprocess.CompletedProcess` object. The value for any stream that was not
captured will be ``None``.

If you want to capture both stdout and stderr while keeping them
separate, pass ``capture_stdout=True, capture_stderr=True``.

If you want to capture both stdout and stderr but mixed together
in the order they were printed, use: ``capture_stdout=True, stderr=subprocess.STDOUT``.
This directs the child's stderr into its stdout, so the combined
output will be available in the `~subprocess.CompletedProcess.stdout`
attribute.

If you're using ``await nursery.start(trio.run_process, ...)`` and want to capture
the subprocess's output for further processing, then use ``stdout=subprocess.PIPE``
and then make sure to read the data out of the `Process.stdout` stream. If you want
to capture stderr separately, use ``stderr=subprocess.PIPE``. If you want to capture
both, but mixed together in the correct order, use ``stdout=subprocess.PIPE,
stderr=subprocess.STDOUT``.

**Error checking:** If the subprocess exits with a nonzero status
code, indicating failure, :func:`run_process` raises a
:exc:`subprocess.CalledProcessError` exception rather than
returning normally. The captured outputs are still available as
the :attr:`~subprocess.CalledProcessError.stdout` and
:attr:`~subprocess.CalledProcessError.stderr` attributes of that
exception.  To disable this behavior, so that :func:`run_process`
returns normally even if the subprocess exits abnormally, pass ``check=False``.

Note that this can make the ``capture_stdout`` and ``capture_stderr``
arguments useful even when starting `run_process` as a task: if you only
care about the output if the process fails, then you can enable capturing
and then read the output off of the `~subprocess.CalledProcessError`.

**Cancellation:** If cancelled, `run_process` sends a termination
request to the subprocess, then waits for it to fully exit. The
``deliver_cancel`` argument lets you control how the process is terminated.

.. note:: `run_process` is intentionally similar to the standard library
   `subprocess.run`, but some of the defaults are different. Specifically, we
   default to:

   - ``check=True``, because `"errors should never pass silently / unless
     explicitly silenced" <https://www.python.org/dev/peps/pep-0020/>`__.

   - ``stdin=b""``, because it produces less-confusing results if a subprocess
     unexpectedly tries to read from stdin.

   To get the `subprocess.run` semantics, use ``check=False, stdin=None``.

Args:
  command (list or str): The command to run. Typically this is a
      sequence of strings such as ``['ls', '-l', 'directory with spaces']``,
      where the first element names the executable to invoke and the other
      elements specify its arguments. With ``shell=True`` in the
      ``**options``, or on Windows, ``command`` may alternatively
      be a string, which will be parsed following platform-dependent
      :ref:`quoting rules <subprocess-quoting>`.

  stdin (:obj:`bytes`, subprocess.PIPE, file descriptor, or None): The
      bytes to provide to the subprocess on its standard input stream, or
      ``None`` if the subprocess's standard input should come from the
      same place as the parent Trio process's standard input. As is the
      case with the :mod:`subprocess` module, you can also pass a file
      descriptor or an object with a ``fileno()`` method, in which case
      the subprocess's standard input will come from that file.

      When starting `run_process` as a background task, you can also use
      ``stdin=subprocess.PIPE``, in which case `Process.stdin` will be a
      `~trio.abc.SendStream` that you can use to send data to the child.

  capture_stdout (bool): If true, capture the bytes that the subprocess
      writes to its standard output stream and return them in the
      `~subprocess.CompletedProcess.stdout` attribute of the returned
      `subprocess.CompletedProcess` or `subprocess.CalledProcessError`.

  capture_stderr (bool): If true, capture the bytes that the subprocess
      writes to its standard error stream and return them in the
      `~subprocess.CompletedProcess.stderr` attribute of the returned
      `~subprocess.CompletedProcess` or `subprocess.CalledProcessError`.

  check (bool): If false, don't validate that the subprocess exits
      successfully. You should be sure to check the
      ``returncode`` attribute of the returned object if you pass
      ``check=False``, so that errors don't pass silently.

  deliver_cancel (async function or None): If `run_process` is cancelled,
      then it needs to kill the child process. There are multiple ways to
      do this, so we let you customize it.

      If you pass None (the default), then the behavior depends on the
      platform:

      - On Windows, Trio calls ``TerminateProcess``, which should kill the
        process immediately.

      - On Unix-likes, the default behavior is to send a ``SIGTERM``, wait
        5 seconds, and send a ``SIGKILL``.

      Alternatively, you can customize this behavior by passing in an
      arbitrary async function, which will be called with the `Process`
      object as an argument. For example, the default Unix behavior could
      be implemented like this::

         async def my_deliver_cancel(process):
             process.send_signal(signal.SIGTERM)
             await trio.sleep(5)
             process.send_signal(signal.SIGKILL)

      When the process actually exits, the ``deliver_cancel`` function
      will automatically be cancelled – so if the process exits after
      ``SIGTERM``, then we'll never reach the ``SIGKILL``.

      In any case, `run_process` will always wait for the child process to
      exit before raising `Cancelled`.

  **options: :func:`run_process` also accepts any :ref:`general subprocess
      options <subprocess-options>` and passes them on to the
      :class:`~trio.Process` constructor. This includes the
      ``stdout`` and ``stderr`` options, which provide additional
      redirection possibilities such as ``stderr=subprocess.STDOUT``,
      ``stdout=subprocess.DEVNULL``, or file descriptors.

Returns:

  When called normally – a `subprocess.CompletedProcess` instance
  describing the return code and outputs.

  When called via `Nursery.start` – a `trio.Process` instance.

Raises:
  UnicodeError: if ``stdin`` is specified as a Unicode string, rather
      than bytes
  ValueError: if multiple redirections are specified for the same
      stream, e.g., both ``capture_stdout=True`` and
      ``stdout=subprocess.DEVNULL``
  subprocess.CalledProcessError: if ``check=False`` is not passed
      and the process exits with a nonzero exit status
  OSError: if an error is encountered starting or communicating with
      the process

.. note:: The child process runs in the same process group as the parent
   Trio process, so a Ctrl+C will be delivered simultaneously to both
   parent and child. If you don't want this behavior, consult your
   platform's documentation for starting child processes in a different
   process group.

Nr%   )r   r   rV   r   r   r   r   rW   rX   r   r   r   r   r   r   s                  r(   run_processr   a  s     b r   r%   )
rV   rW   rX   r   r   r   
preexec_fnrestore_signalsstart_new_sessionpass_fdsc                  #    g 7fr$   r%   r   rV   rW   rX   r   r   r   r   r   r   r   r   s               r(   r   r   8  
      r   )rV   rW   rX   r   r   r   r   r   r   r   r   c                  #    g 7fr$   r%   r   s               r(   r   r   I  r   r   )r   rV   r   r   r   r   rW   rX   r   r   r   r   r   r   r   c                  #    g 7fr$   r%   r   r   rV   r   r   r   r   rW   rX   r   r   r   r   r   r   r   r   s                    r(   r   r   Z  
     ( 25r   )r   rV   r   r   r   r   rW   rX   r   r   r   r   r   r   r   r   c                  #    g 7fr$   r%   r   s                    r(   r   r   p  r   r   r   r   )r&   rE   r'   rE   rD   rE   )r   )StrOrBytesPath | Sequence[StrOrBytesPath]rV   int | HasFileno | NonerW   r   rX   r   r   rR   rD   rM   )r   rM   rD   r   )r   r   rV   7bytes | bytearray | memoryview | int | HasFileno | Noner   r!   r   r!   r   r!   r   -Callable[[Process], Awaitable[object]] | Noner   TaskStatus[Process]r   rR   rD   "subprocess.CompletedProcess[bytes])r   r   rV   r   rW   r   rX   r   r   r!   r   r!   r   StrOrBytesPath | Noner   Mapping[str, str] | Noner   subprocess.STARTUPINFO | Noner   rE   rD   trio.Process) r   r   r   r   rV   r   r   r!   r   r!   r   r!   r   r   rW   r   rX   r   r   r!   r   r!   r   r   r   r  r   r  r   rE   rD   r   )r   r    rV   r   rW   r   rX   r   r   r!   r   Literal[True]r   r   r   r  r   Callable[[], object] | Noner   r!   r   r!   r   Sequence[int]rD   r  )r   Sequence[StrOrBytesPath]rV   r   rW   r   rX   r   r   r!   r   r!   r   r   r   r  r   r  r   r!   r   r!   r   r  rD   r  )$r   r    r   r   rV   r   r   r!   r   r!   r   r!   r   r   rW   r   rX   r   r   r!   r   r  r   r   r   r  r   r  r   r!   r   r!   r   r  rD   r   )$r   r  r   r   rV   r   r   r!   r   r!   r   r!   r   z+Callable[[Process], Awaitable[None]] | NonerW   r   rX   r   r   r!   r   r!   r   r   r   r  r   r  r   r!   r   r!   r   r  rD   r   )L
__future__r   rs   r7   r   sysr   r   	functoolsr   typingr   r   r   r	   r
   r   rm   _corer   r   _highlevel_genericr   _subprocess_platformr   r   r   _syncr   _utilr   r   signalcollections.abcr   r   r   r   ior   typing_extensionsr   _abcr   r   version_infor   r   PathLiker    r   r)   r+   r,   r"   ImportErrorplatformr4   CDLLr1   c_longr2   restypeargtypesr3   r<   rM   r   r   r   r   r   r   r   rF   rH   r%   r*   r(   <module>r     s   "  	  
     K K  2 - 
  -FF +/ v %c5"++c2BBKKPUDV&V WNIW %	!NI   3OO &'!P! ! F+ F FX %)%)%)|H6|H "|H #	|H
 #|H |H |H~

2 FI  DH'+'?'?~W6~W C~W 	~W
 ~W ~W B~W %~W ~W (~WX
 
||w
 -1-1-1")-,09=!"?	>?	 *?	 +	?	
 +?	 ?	 ?	 '?	 *?	 7?	 ?	 ?	H 04/G/GMQ#(#(LP-1-1")-,09=!"!Q	>Q	 -Q	 K	Q	
 !Q	 !Q	 Q	 JQ	 +Q	 +Q	 Q	 Q	 'Q	 *Q	 7Q	  !Q	" 0#Q	n 
 -1-1-1")-,06:$(&+&(	#	 *	 +		
 +	 	 !	 '	 *	 4	 "	  $	 $	 	 
	  
 -1-1-1")-,06:$(&+&(	-	 *	 +		
 +	 	 	 '	 *	 4	 "	  $	 $	 	 
	  
 04/G/GMQ#(#(LP-1-1")-,06:$(&+&(%	5#	5 -	5 K		5
 !	5 !	5 	5 J	5 +	5 +	5 	5 !	5 '	5 *	5 4	5  "!	5"  $#	5$ $%	5& 0'	5 
	5* 
 04/G/GMQ#(#(JN-1-1")-,06:$(&+&(%	5-	5 -	5 K		5
 !	5 !	5 	5 H	5 +	5 +	5 	5 	5 '	5 *	5 4	5  "!	5"  $#	5$ $%	5& 0'	5 
	5. !L8FFLL5K6CCK;3c"  $'<<7" #);;tt#D 39== ((0 5 ((1
 "O "'I$'s   1K- -A?M5/M54M5