diff options
Diffstat (limited to 'bitbake/lib/hashserv/client.py')
-rw-r--r-- | bitbake/lib/hashserv/client.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/bitbake/lib/hashserv/client.py b/bitbake/lib/hashserv/client.py index d415617b20..a510f3284f 100644 --- a/bitbake/lib/hashserv/client.py +++ b/bitbake/lib/hashserv/client.py | |||
@@ -121,24 +121,28 @@ class AsyncClient(bb.asyncrpc.AsyncClient): | |||
121 | 121 | ||
122 | return await self._send_wrapper(proc) | 122 | return await self._send_wrapper(proc) |
123 | 123 | ||
124 | async def invoke(self, *args, **kwargs): | 124 | async def invoke(self, *args, skip_mode=False, **kwargs): |
125 | # It's OK if connection errors cause a failure here, because the mode | 125 | # It's OK if connection errors cause a failure here, because the mode |
126 | # is also reset to normal on a new connection | 126 | # is also reset to normal on a new connection |
127 | await self._set_mode(self.MODE_NORMAL) | 127 | if not skip_mode: |
128 | await self._set_mode(self.MODE_NORMAL) | ||
128 | return await super().invoke(*args, **kwargs) | 129 | return await super().invoke(*args, **kwargs) |
129 | 130 | ||
130 | async def _set_mode(self, new_mode): | 131 | async def _set_mode(self, new_mode): |
131 | async def stream_to_normal(): | 132 | async def stream_to_normal(): |
133 | # Check if already in normal mode (e.g. due to a connection reset) | ||
134 | if self.mode == self.MODE_NORMAL: | ||
135 | return "ok" | ||
132 | await self.socket.send("END") | 136 | await self.socket.send("END") |
133 | return await self.socket.recv() | 137 | return await self.socket.recv() |
134 | 138 | ||
135 | async def normal_to_stream(command): | 139 | async def normal_to_stream(command): |
136 | r = await self.invoke({command: None}) | 140 | r = await self.invoke({command: None}, skip_mode=True) |
137 | if r != "ok": | 141 | if r != "ok": |
142 | self.check_invoke_error(r) | ||
138 | raise ConnectionError( | 143 | raise ConnectionError( |
139 | f"Unable to transition to stream mode: Bad response from server {r!r}" | 144 | f"Unable to transition to stream mode: Bad response from server {r!r}" |
140 | ) | 145 | ) |
141 | |||
142 | self.logger.debug("Mode is now %s", command) | 146 | self.logger.debug("Mode is now %s", command) |
143 | 147 | ||
144 | if new_mode == self.mode: | 148 | if new_mode == self.mode: |