Improve dht shutdown. Notice writing pauses.
This commit is contained in:
parent
4515fa8b0a
commit
d04634b57b
@ -52,6 +52,7 @@ class DisposablePeer:
|
|||||||
|
|
||||||
self._metadata_future = loop.create_future()
|
self._metadata_future = loop.create_future()
|
||||||
self._writer = None
|
self._writer = None
|
||||||
|
self._is_paused = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._reader, self._writer = await asyncio.open_connection(
|
self._reader, self._writer = await asyncio.open_connection(
|
||||||
@ -88,6 +89,12 @@ class DisposablePeer:
|
|||||||
self._writer.close()
|
self._writer.close()
|
||||||
return self._metadata_future.result()
|
return self._metadata_future.result()
|
||||||
|
|
||||||
|
def pause_writing(self):
|
||||||
|
self._is_paused = True
|
||||||
|
|
||||||
|
def resume_writing(self):
|
||||||
|
self._is_paused = False
|
||||||
|
|
||||||
def __on_message(self, message: bytes) -> None:
|
def __on_message(self, message: bytes) -> None:
|
||||||
length = len(message)
|
length = len(message)
|
||||||
|
|
||||||
|
@ -84,6 +84,9 @@ class SybilNode:
|
|||||||
if addr[1] == 0:
|
if addr[1] == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self._transport.is_closing():
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
message = bencode.loads(data)
|
message = bencode.loads(data)
|
||||||
except bencode.BencodeDecodingError:
|
except bencode.BencodeDecodingError:
|
||||||
|
Loading…
Reference in New Issue
Block a user