Handle situation when SAM API goes offline while waiting for reply

master
Viktor Villainov 2019-01-26 06:50:50 -05:00
parent 5595cf658e
commit 1e1fc4c750
No known key found for this signature in database
GPG Key ID: 8EB38B46F33BAF2F
1 changed files with 3 additions and 0 deletions

View File

@ -8,6 +8,9 @@ import i2plib.utils
BUFFER_SIZE = 65536
def parse_reply(data):
if not data:
raise ConnectionAbortedError("Empty response: SAM API went offline")
return i2plib.sam.Message(data.split(b"\n")[0].decode())
async def get_sam_socket(sam_address=i2plib.sam.DEFAULT_ADDRESS, loop=None):