launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25100
Re: [Merge] ~pappacena/launchpad:poll-for-librarian-client into launchpad:master
Diff comments:
> diff --git a/lib/lp/services/librarian/client.py b/lib/lp/services/librarian/client.py
> index 4007016..877e51c 100644
> --- a/lib/lp/services/librarian/client.py
> +++ b/lib/lp/services/librarian/client.py
> @@ -98,20 +98,31 @@ class FileUploadClient:
> self.state.s = socket.socket(AF_INET, SOCK_STREAM)
> self.state.s.connect((self.upload_host, self.upload_port))
> self.state.f = self.state.s.makefile('rwb', 0)
> +
> + # Register epoll for the socket.
> + self.state.s_poll = select.epoll()
> + self.state.s_poll.register(self.state.s.fileno(), select.EPOLLIN)
> except socket.error as x:
> raise UploadFailed(
> '[%s:%s]: %s' % (self.upload_host, self.upload_port, x))
>
> def _close(self):
> """Close connection"""
> + self.state.s_poll.unregister(self.state.s.fileno())
> + self.state.s_poll.close()
> + del self.state.s_poll
> del self.state.s
> del self.state.f
>
> def _checkError(self):
> - if select([self.state.s], [], [], 0)[0]:
> + poll_result = self.state.s_poll.poll(0)
> + if poll_result:
> + fileno, event = poll_result[0]
> + assert fileno == self.state.s.fileno()
> + assert event == select.EPOLLIN
> response = six.ensure_str(
> self.state.f.readline().strip(), errors='replace')
> - raise UploadFailed('Server said: ' + response)
> + raise UploadFailed('Server said early: ' + response)
Making the error message slightly different from the other UploadFailed raised in this class, in order to make it easier to debug and test.
>
> def _sendLine(self, line, check_for_error_responses=True):
> self.state.f.write(six.ensure_binary(line + '\r\n'))
--
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/388315
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:poll-for-librarian-client into launchpad:master.