mirror of https://github.com/m-labs/artiq.git
afws_client: asyncio fixes
This commit is contained in:
parent
8f0147f029
commit
c785c763fe
|
@ -72,11 +72,11 @@ class Client:
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
if self.writer:
|
if self.writer:
|
||||||
await self.writer.close()
|
self.writer.close()
|
||||||
await self.writer.wait_closed()
|
await self.writer.wait_closed()
|
||||||
|
|
||||||
async def send_command(self, *command):
|
async def send_command(self, *command):
|
||||||
await self.writer.write((" ".join(command) + "\n").encode())
|
self.writer.write((" ".join(command) + "\n").encode())
|
||||||
|
|
||||||
async def read_line(self):
|
async def read_line(self):
|
||||||
return (await self.reader.readline()).decode("ascii")
|
return (await self.reader.readline()).decode("ascii")
|
||||||
|
@ -120,7 +120,7 @@ class Client:
|
||||||
if status != "done":
|
if status != "done":
|
||||||
return status, None
|
return status, None
|
||||||
print("Build completed. Downloading...")
|
print("Build completed. Downloading...")
|
||||||
reply, length = self.read_reply()
|
reply, length = await self.read_reply()
|
||||||
if reply != "PRODUCT":
|
if reply != "PRODUCT":
|
||||||
raise ValueError("Unexpected server reply: expected 'PRODUCT', got '{}'".format(reply))
|
raise ValueError("Unexpected server reply: expected 'PRODUCT', got '{}'".format(reply))
|
||||||
length = int(length)
|
length = int(length)
|
||||||
|
@ -129,7 +129,7 @@ class Client:
|
||||||
total = 0
|
total = 0
|
||||||
while total != length:
|
while total != length:
|
||||||
chunk_len = min(4096, length-total)
|
chunk_len = min(4096, length-total)
|
||||||
contents += self.fsocket.read(chunk_len)
|
contents += await self.reader.read(chunk_len)
|
||||||
total += chunk_len
|
total += chunk_len
|
||||||
progress_bar.update(chunk_len)
|
progress_bar.update(chunk_len)
|
||||||
print("Download completed.")
|
print("Download completed.")
|
||||||
|
|
Loading…
Reference in New Issue