summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/hashserv
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/hashserv')
-rw-r--r--bitbake/lib/hashserv/client.py20
-rw-r--r--bitbake/lib/hashserv/tests.py3
2 files changed, 9 insertions, 14 deletions
diff --git a/bitbake/lib/hashserv/client.py b/bitbake/lib/hashserv/client.py
index e05c1eb568..f370cba63f 100644
--- a/bitbake/lib/hashserv/client.py
+++ b/bitbake/lib/hashserv/client.py
@@ -14,10 +14,6 @@ from . import chunkify, DEFAULT_MAX_CHUNK, create_async_client
14logger = logging.getLogger("hashserv.client") 14logger = logging.getLogger("hashserv.client")
15 15
16 16
17class HashConnectionError(Exception):
18 pass
19
20
21class AsyncClient(object): 17class AsyncClient(object):
22 MODE_NORMAL = 0 18 MODE_NORMAL = 0
23 MODE_GET_STREAM = 1 19 MODE_GET_STREAM = 1
@@ -66,14 +62,14 @@ class AsyncClient(object):
66 return await proc() 62 return await proc()
67 except ( 63 except (
68 OSError, 64 OSError,
69 HashConnectionError, 65 ConnectionError,
70 json.JSONDecodeError, 66 json.JSONDecodeError,
71 UnicodeDecodeError, 67 UnicodeDecodeError,
72 ) as e: 68 ) as e:
73 logger.warning("Error talking to server: %s" % e) 69 logger.warning("Error talking to server: %s" % e)
74 if count >= 3: 70 if count >= 3:
75 if not isinstance(e, HashConnectionError): 71 if not isinstance(e, ConnectionError):
76 raise HashConnectionError(str(e)) 72 raise ConnectionError(str(e))
77 raise e 73 raise e
78 await self.close() 74 await self.close()
79 count += 1 75 count += 1
@@ -82,12 +78,12 @@ class AsyncClient(object):
82 async def get_line(): 78 async def get_line():
83 line = await self.reader.readline() 79 line = await self.reader.readline()
84 if not line: 80 if not line:
85 raise HashConnectionError("Connection closed") 81 raise ConnectionError("Connection closed")
86 82
87 line = line.decode("utf-8") 83 line = line.decode("utf-8")
88 84
89 if not line.endswith("\n"): 85 if not line.endswith("\n"):
90 raise HashConnectionError("Bad message %r" % message) 86 raise ConnectionError("Bad message %r" % message)
91 87
92 return line 88 return line
93 89
@@ -119,7 +115,7 @@ class AsyncClient(object):
119 await self.writer.drain() 115 await self.writer.drain()
120 l = await self.reader.readline() 116 l = await self.reader.readline()
121 if not l: 117 if not l:
122 raise HashConnectionError("Connection closed") 118 raise ConnectionError("Connection closed")
123 return l.decode("utf-8").rstrip() 119 return l.decode("utf-8").rstrip()
124 120
125 return await self._send_wrapper(proc) 121 return await self._send_wrapper(proc)
@@ -128,11 +124,11 @@ class AsyncClient(object):
128 if new_mode == self.MODE_NORMAL and self.mode == self.MODE_GET_STREAM: 124 if new_mode == self.MODE_NORMAL and self.mode == self.MODE_GET_STREAM:
129 r = await self.send_stream("END") 125 r = await self.send_stream("END")
130 if r != "ok": 126 if r != "ok":
131 raise HashConnectionError("Bad response from server %r" % r) 127 raise ConnectionError("Bad response from server %r" % r)
132 elif new_mode == self.MODE_GET_STREAM and self.mode == self.MODE_NORMAL: 128 elif new_mode == self.MODE_GET_STREAM and self.mode == self.MODE_NORMAL:
133 r = await self.send_message({"get-stream": None}) 129 r = await self.send_message({"get-stream": None})
134 if r != "ok": 130 if r != "ok":
135 raise HashConnectionError("Bad response from server %r" % r) 131 raise ConnectionError("Bad response from server %r" % r)
136 elif new_mode != self.mode: 132 elif new_mode != self.mode:
137 raise Exception( 133 raise Exception(
138 "Undefined mode transition %r -> %r" % (self.mode, new_mode) 134 "Undefined mode transition %r -> %r" % (self.mode, new_mode)
diff --git a/bitbake/lib/hashserv/tests.py b/bitbake/lib/hashserv/tests.py
index 1a696481e3..e2b762dbf0 100644
--- a/bitbake/lib/hashserv/tests.py
+++ b/bitbake/lib/hashserv/tests.py
@@ -6,7 +6,6 @@
6# 6#
7 7
8from . import create_server, create_client 8from . import create_server, create_client
9from .client import HashConnectionError
10import hashlib 9import hashlib
11import logging 10import logging
12import multiprocessing 11import multiprocessing
@@ -277,7 +276,7 @@ class HashEquivalenceCommonTests(object):
277 outhash2 = '3c979c3db45c569f51ab7626a4651074be3a9d11a84b1db076f5b14f7d39db44' 276 outhash2 = '3c979c3db45c569f51ab7626a4651074be3a9d11a84b1db076f5b14f7d39db44'
278 unihash2 = '90e9bc1d1f094c51824adca7f8ea79a048d68824' 277 unihash2 = '90e9bc1d1f094c51824adca7f8ea79a048d68824'
279 278
280 with self.assertRaises(HashConnectionError): 279 with self.assertRaises(ConnectionError):
281 ro_client.report_unihash(taskhash2, self.METHOD, outhash2, unihash2) 280 ro_client.report_unihash(taskhash2, self.METHOD, outhash2, unihash2)
282 281
283 # Ensure that the database was not modified 282 # Ensure that the database was not modified