+
     i  c                   sj    R t ^ RIt^ RIt^ RIt^ RIt^ RIHtHtHt ^ RI	H
t
 ^ RIHt  ! R R4      tR# )zNamed bidirectional non-blocking pipes.

>>> p1 = Pipe('foo')
>>> p2 = Pipe('foo')

>>> p1.send(1)
>>> p2.poll()
>>> p2.recv()

>>> p2.send(2)
>>> p1.poll()
>>> p1.recv()

Beware that pipes read any available messages,
even those written by themselves.
N)OptionalAsyncIteratorUnion)	PathUtils)loggerc                   sx   a  ] tR t^0t o RtR tR tR tV 3R lR ltV 3R lR lt	R	 t
R
 tR tR tR tRtV tR# )PipezPipe object.

This is not for secure communication. If pipes already exist, they will be used,
but existing pipes might have open permissions! Only use this for stuff that
non-privileged users would be allowed to read.
c                s   Wn         . V n        \        P                  ! 4       V n        RV n        RV n        V R2V R23p\        P                  ! \        P                  P                  V4      4       \        P                  P                  V^ ,          4      '       Eg   \        P                  ! RV4       \        P                  P                  V^ ,          4      '       d   \        P                  ! V^ ,          4       \        P                  P                  V^,          4      '       d   \        P                  ! V^,          4       \        P                   ! 4       V n        R\        P$                  ! 4        R2p\        P&                  ! V V P"                  ^ ,           24       \        P&                  ! V V P"                  ^,           24       \        P(                  ! V V P"                  ^ ,           2V^ ,          4       \        P(                  ! V V P"                  ^,           2V^,          4       M\        P                  ! RV4       \        P*                  ! V^ ,          \        P,                  \        P.                  ,          4      \        P*                  ! V^,          \        P0                  \        P.                  ,          4      3V n        \+        V P"                  ^ ,          R4      \+        V P"                  ^,          R4      3V n        V P5                  4       '       d*   V P7                  4       p\        P                  ! RV4       K?  R# )	z/Create a pipe, or open it if it already exists.NZrZwzCreating new pipes %sz/proc/z/fd/zUsing existing pipes %szCleared leftover message "%s")_path_unreadtime_created_at
_transport_async_iteratorr   ZmkdirospathZdirnameZexistsr   debugZislinkZremoveZpipe_fdsZgetpidZchownZsymlinkZopenZO_RDONLYZ
O_NONBLOCKZO_WRONLY_handlespollrecv)selfr   ZpathsZfds_dirZleftovers   &&   ;/usr/lib/python3.14/site-packages/inputremapper/ipc/pipe.py__init__ZPipe.__init__8   s#   
99;;?8<6vQZ(-.ww~~eAh''LL0%8 ww~~eAh''		%(#ww~~eAh''		%(#	DIryy{m40GOOwi		!~67OOwi		!~67 JJ'499Q<.158<JJ'499Q<.158<LL2E:
 GGE!HbkkBMM9:GGE!HbkkBMM9:
	
 diilC0$tyy|S2IJ iikkyy{HLL8(C     c                s    V P                   '       d1   \        P                  ! R 4       V P                   P                  4        V P                   F  pVP                  4        K  	  R# )zclosing transportN)r
   r   r   Zcloser   )r   Zfile   & r   __del__ZPipe.__del__h   s?    ???LL,-OO!!#MMDJJL "r   c                s    \        V P                  4      ^ 8  d   V P                  P                  ^ 4      # V P                  ^ ,          P	                  4       p\        V4      ^ 8X  d   R# V P                  V4      # )zRead an object from the pipe or None if nothing available.

Doesn't transmit pickles, to avoid injection attacks on the
privileged reader-service. Only messages that can be converted to json
are allowed.
N)lenr   Zpopr   Zreadline_get_msg)r   liner   r   r   Z	Pipe.recvo   s^     t||q <<##A&&}}Q((*t9>}}T""r   c                s    < V ^8  d   QhRS[ /# )   r   )strZformat__classdict__   "r   __annotate__Pipe.__annotate__   s     	 	S 	r   c                s    \         P                  ! V4      pV^ ,          V P                  8  d?   \        P                  P                  R4      '       d   \        P                  ! RV4       R# V^,          # )i    ZUNITTESTzIgnoring old message %sN)jsonZloadsr	   r   ZenvironZgetr   r   )r   r   Zparsed   && r   r   ZPipe._get_msg   sR    D!!9t'''BJJNN:,F,F LL2F;ayr   c                sF   < V ^8  d   QhRS[ S[S[S[S[S[S[3,          /# )r   message)r   r   ZintZfloatZdictZlistZtupler   r    r   r!   r"      s&     ! !E#sE4u"DE !r   c                sF   \         P                  ! \        P                  ! 4       V34      pV P                  ^,          P	                  VP                  RR4      4       V P                  ^,          P	                  R4       V P                  ^,          P                  4        R# )z(Write a serializable object to the pipe.Z
Z N)r#   Zdumpsr   r   ZwriteZreplaceZflush)r   r%   Zdumpr$   r   sendZ	Pipe.send   sk    zz499;01 	at||D"56at$a r   c                s    \        V P                  4      ^ 8  d   R# V P                  4       pVe   V P                  P                  V4       \        V P                  4      ^ 8  # )z,Check if there is anything that can be read.T)r   r   r   Zappend)r   Zmsgr   r   r   Z	Pipe.poll   sN    t||q 
 iik?LL$4<< 1$$r   c                sD    V P                   ^ ,          P                  4       # )zCompatibility to select.select.)r   filenor      &r   r'   ZPipe.fileno   s    }}Q&&((r   c                s    V # N r(   r)   r   	__aiter__ZPipe.__aiter__   s    r   c                s  a"   V P                   '       gw   \        P                  ! 4       p\        P                  ! 4       oVP	                  V3R  lV P
                  ^ ,          4      G Rj  xL
 w  V n        pSP                  4       V n         T P                  V P                   P                  4       G Rj  xL
 4      #  LR L
5i)c                  s0   < \         P                  ! S 4      # r*   )asyncioZStreamReaderProtocol)readers   r   Z<lambda>Z Pipe.__anext__.<locals>.<lambda>   s    44V<r   N)
r   r-   Zget_running_loopZStreamReaderZconnect_read_piper   r
   r,   r   	__anext__)r   ZloopZ_r.   s   &  @r   r/   ZPipe.__anext__   s     ###++-D))+F'+'='=<dmmA>N( "DOQ $*#3#3#5D }}4#7#7#A#A#CCDD"
 Ds%   A'C*B=+A	C4B?5	C?Cc                sZ   "   V P                  4       P                  4       G Rj  xL
 #  L5i)zMRead the next line with async. Do not use this when using
the async for loop.N)r,   r/   r(   r)   r   
recv_asyncZPipe.recv_async   s#      ^^%//1111s   "+)+)r   r	   r   r   r   r
   r   N)Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r   r   r   r   r&   r   r'   r,   r/   r0   Z__static_attributes__Z__classdictcell__)r   s   @r   r   r   0   sN     .D`# 	 	! !%)
E2 2r   r   )r1   r-   r#   r   r   Ztypingr    r   r   Zinputremapper.configs.pathsr   Zinputremapper.logging.loggerr   r   r+   r   r   <module>r2      s0   *"   	  1 1 1 /G2 G2r   