Merge branch 'master' into f-string_clean
# Conflicts: # libp2p/network/connection/raw_connection.py
This commit is contained in:
commit
4c3510f738
|
@ -26,10 +26,11 @@ class RawConnection(IRawConnection):
|
||||||
|
|
||||||
async def write(self, data: bytes) -> None:
|
async def write(self, data: bytes) -> None:
|
||||||
"""Raise `RawConnError` if the underlying connection breaks."""
|
"""Raise `RawConnError` if the underlying connection breaks."""
|
||||||
try:
|
# Detect if underlying transport is closing before write data to it
|
||||||
self.writer.write(data)
|
# ref: https://github.com/ethereum/trinity/pull/614
|
||||||
except ConnectionResetError as error:
|
if self.writer.transport.is_closing():
|
||||||
raise RawConnError() from error
|
raise RawConnError("Transport is closing")
|
||||||
|
self.writer.write(data)
|
||||||
# Reference: https://github.com/ethereum/lahja/blob/93610b2eb46969ff1797e0748c7ac2595e130aef/lahja/asyncio/endpoint.py#L99-L102 # noqa: E501
|
# Reference: https://github.com/ethereum/lahja/blob/93610b2eb46969ff1797e0748c7ac2595e130aef/lahja/asyncio/endpoint.py#L99-L102 # noqa: E501
|
||||||
# Use a lock to serialize drain() calls. Circumvents this bug:
|
# Use a lock to serialize drain() calls. Circumvents this bug:
|
||||||
# https://bugs.python.org/issue29930
|
# https://bugs.python.org/issue29930
|
||||||
|
@ -52,7 +53,13 @@ class RawConnection(IRawConnection):
|
||||||
raise RawConnError() from error
|
raise RawConnError() from error
|
||||||
|
|
||||||
async def close(self) -> None:
|
async def close(self) -> None:
|
||||||
|
if self.writer.transport.is_closing():
|
||||||
|
return
|
||||||
self.writer.close()
|
self.writer.close()
|
||||||
if sys.version_info < (3, 7):
|
if sys.version_info < (3, 7):
|
||||||
return
|
return
|
||||||
await self.writer.wait_closed()
|
try:
|
||||||
|
await self.writer.wait_closed()
|
||||||
|
# In case the connection is already reset.
|
||||||
|
except ConnectionResetError:
|
||||||
|
return
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -66,7 +66,7 @@ install_requires = [
|
||||||
"pycryptodome>=3.9.2,<4.0.0",
|
"pycryptodome>=3.9.2,<4.0.0",
|
||||||
"base58>=1.0.3,<2.0.0",
|
"base58>=1.0.3,<2.0.0",
|
||||||
"pymultihash>=0.8.2",
|
"pymultihash>=0.8.2",
|
||||||
"multiaddr>=0.0.8,<0.1.0",
|
"multiaddr>=0.0.9,<0.1.0",
|
||||||
"rpcudp>=3.0.0,<4.0.0",
|
"rpcudp>=3.0.0,<4.0.0",
|
||||||
"lru-dict>=1.1.6",
|
"lru-dict>=1.1.6",
|
||||||
"protobuf>=3.10.0,<4.0.0",
|
"protobuf>=3.10.0,<4.0.0",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user