Merge ~twom/launchpad:revert-897463a14e165e8e46d2b65f6cfad6dc02bf7fd4 into launchpad:master

Proposed by Tom Wardill
Status: Merged
Approved by: Kristian Glass
Approved revision: a4b182999a8baf900edf358a0881307db06ad79e
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:revert-897463a14e165e8e46d2b65f6cfad6dc02bf7fd4
Merge into: launchpad:master
Diff against target: 42 lines (+1/-12)
2 files modified
lib/lp/services/librarian/client.py (+1/-2)
lib/lp/services/librarian/tests/test_client.py (+0/-10)
Reviewer Review Type Date Requested Status
Kristian Glass (community) Approve
Review via email: mp+389320@code.launchpad.net

Commit message

Revert "Avoiding race condition at librarian client test"

Description of the change

Causing OOPS in threading scenarios

To post a comment you must log in.
Revision history for this message
Kristian Glass (doismellburning) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/librarian/client.py b/lib/lp/services/librarian/client.py
2index ba18805..737d9e4 100644
3--- a/lib/lp/services/librarian/client.py
4+++ b/lib/lp/services/librarian/client.py
5@@ -88,7 +88,6 @@ class FileUploadClient:
6 # it will be shared between threads. The easiest way of making this
7 # class thread safe is by storing all state in a thread local.
8 self.state = threading.local()
9- self.state.s_poll_timeout = 0
10
11 def _connect(self):
12 """Connect this client.
13@@ -116,7 +115,7 @@ class FileUploadClient:
14 del self.state.f
15
16 def _checkError(self):
17- poll_result = self.state.s_poll.poll(self.state.s_poll_timeout)
18+ poll_result = self.state.s_poll.poll(0)
19 if poll_result:
20 fileno, event = poll_result[0]
21 # Accepts any event that contains input data. Even if we
22diff --git a/lib/lp/services/librarian/tests/test_client.py b/lib/lp/services/librarian/tests/test_client.py
23index 3b406c1..e00a86e 100644
24--- a/lib/lp/services/librarian/tests/test_client.py
25+++ b/lib/lp/services/librarian/tests/test_client.py
26@@ -252,16 +252,6 @@ class LibrarianClientTestCase(TestCase):
27 'librarian', upload_host=upload_host, upload_port=upload_port)
28
29 client = LibrarianClient()
30- # Artificially increases timeout to avoid race condition.
31- # The fake server is running in another thread, and we are sure it
32- # will (eventually) reply with an error message. So, let's just wait
33- # until that message arrives.
34- client.state.s_poll_timeout = 120
35-
36- # Please, note the mismatch between file size (7) and its actual size
37- # of the content (6). This is intentional, to make sure we are raising
38- # the error coming from the fake server (and not the local check
39- # right after, while uploading the file).
40 self.assertRaisesRegex(
41 UploadFailed, 'Server said early: STORE 7 sample.txt',
42 client.addFile, 'sample.txt', 7, StringIO('sample'), 'text/plain')

Subscribers

People subscribed via source and target branches

to status/vote changes: