1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
U
Z±dXã@sVddlZddlZddlmZddlmZdd„ZejdddGd    d
„d
eed ƒZdS) éNé)ÚHalfCloseableStream)ÚFinalc    Ãs.t ¡}| ¡| ¡IdHW5QRXdS)aëClose an async resource or async generator immediately, without
    blocking to do any graceful cleanup.
 
    :class:`~trio.abc.AsyncResource` objects guarantee that if their
    :meth:`~trio.abc.AsyncResource.aclose` method is cancelled, then they will
    still close the resource (albeit in a potentially ungraceful
    fashion). :func:`aclose_forcefully` is a convenience function that
    exploits this behavior to let you force a resource to be closed without
    blocking: it works by calling ``await resource.aclose()`` and then
    cancelling it immediately.
 
    Most users won't need this, but it may be useful on cleanup paths where
    you can't afford to block, or if you want to close a resource and don't
    care about handling it gracefully. For example, if
    :class:`~trio.SSLStream` encounters an error and cannot perform its
    own graceful close, then there's no point in waiting to gracefully shut
    down the underlying transport either, so it calls ``await
    aclose_forcefully(self.transport_stream)``.
 
    Note that this function is async, and that it acts as a checkpoint, but
    unlike most async functions it cannot block indefinitely (at least,
    assuming the underlying resource object is correctly implemented).
 
    N)ÚtrioZ CancelScopeÚcancelÚaclose)ÚresourceÚcs©r
úNd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\trio/_highlevel_generic.pyÚaclose_forcefully    s
r F)ÚeqÚhashc@sJeZdZdZe ¡Ze ¡Zdd„Zdd„Z    dd„Z
d d    d
„Z d d „Z dS)Ú StapledStreama–This class `staples <https://en.wikipedia.org/wiki/Staple_(fastener)>`__
    together two unidirectional streams to make single bidirectional stream.
 
    Args:
      send_stream (~trio.abc.SendStream): The stream to use for sending.
      receive_stream (~trio.abc.ReceiveStream): The stream to use for
          receiving.
 
    Example:
 
       A silly way to make a stream that echoes back whatever you write to
       it::
 
          left, right = trio.testing.memory_stream_pair()
          echo_stream = StapledStream(SocketStream(left), SocketStream(right))
          await echo_stream.send_all(b"x")
          assert await echo_stream.receive_some() == b"x"
 
    :class:`StapledStream` objects implement the methods in the
    :class:`~trio.abc.HalfCloseableStream` interface. They also have two
    additional public attributes:
 
    .. attribute:: send_stream
 
       The underlying :class:`~trio.abc.SendStream`. :meth:`send_all` and
       :meth:`wait_send_all_might_not_block` are delegated to this object.
 
    .. attribute:: receive_stream
 
       The underlying :class:`~trio.abc.ReceiveStream`. :meth:`receive_some`
       is delegated to this object.
 
    cÃs|j |¡IdHS)z$Calls ``self.send_stream.send_all``.N)Ú send_streamÚsend_all)ÚselfÚdatar
r
r rNszStapledStream.send_allcÃs|j ¡IdHS)z9Calls ``self.send_stream.wait_send_all_might_not_block``.N)rÚwait_send_all_might_not_block©rr
r
r rRsz+StapledStream.wait_send_all_might_not_blockcÃs0t|jdƒr|j ¡IdHS|j ¡IdHSdS)zªShuts down the send side of the stream.
 
        If ``self.send_stream.send_eof`` exists, then calls it. Otherwise,
        calls ``self.send_stream.aclose()``.
 
        Úsend_eofN)Úhasattrrrrrr
r
r rVs zStapledStream.send_eofNcÃs|j |¡IdHS)z+Calls ``self.receive_stream.receive_some``.N)Úreceive_streamÚ receive_some)rZ    max_bytesr
r
r rbszStapledStream.receive_somecÃs,z|j ¡IdHW5|j ¡IdHXdS)z,Calls ``aclose`` on both underlying streams.N)rrrrr
r
r rfszStapledStream.aclose)N) Ú__name__Ú
__module__Ú __qualname__Ú__doc__ÚattrÚibrrrrrrrr
r
r
r r's"
r)Ú    metaclass)    rrÚabcrZ
trio._utilrr Úsrr
r
r
r Ú<module>s