Skip to content

Commit

Permalink
Updated TLSStream to call aclose_forcefully() on exception
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Jul 31, 2020
1 parent 44a197b commit a1c7538
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/anyio/streams/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,15 @@ async def unwrap(self) -> Tuple[AnyByteStream, bytes]:
return self.transport_stream, self._read_bio.read()

async def aclose(self) -> None:
try:
if self.standard_compatible:
if self.standard_compatible:
try:
await self.unwrap()
finally:
await self.transport_stream.aclose()
except BaseException:
from .. import aclose_forcefully
await aclose_forcefully(self.transport_stream)
raise

await self.transport_stream.aclose()

async def receive(self, max_bytes: int = 65536) -> bytes:
return await self._call_sslobject_method(self._ssl_object.read, max_bytes)
Expand Down

0 comments on commit a1c7538

Please sign in to comment.