bpo-31234: Add support.join_thread() helper (#3587) · python/cpython@b9b6900 (original) (raw)
`@@ -123,9 +123,7 @@ def line_terminator_check(self, term, server_chunk):
`
123
123
`c.push(b"I'm not dead yet!" + term)
`
124
124
`c.push(SERVER_QUIT)
`
125
125
`asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
`
126
``
`-
s.join(timeout=TIMEOUT)
`
127
``
`-
if s.is_alive():
`
128
``
`-
self.fail("join() timed out")
`
``
126
`+
support.join_thread(s, timeout=TIMEOUT)
`
129
127
``
130
128
`self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
`
131
129
``
`@@ -156,9 +154,7 @@ def numeric_terminator_check(self, termlen):
`
156
154
`c.push(data)
`
157
155
`c.push(SERVER_QUIT)
`
158
156
`asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
`
159
``
`-
s.join(timeout=TIMEOUT)
`
160
``
`-
if s.is_alive():
`
161
``
`-
self.fail("join() timed out")
`
``
157
`+
support.join_thread(s, timeout=TIMEOUT)
`
162
158
``
163
159
`self.assertEqual(c.contents, [data[:termlen]])
`
164
160
``
`@@ -178,9 +174,7 @@ def test_none_terminator(self):
`
178
174
`c.push(data)
`
179
175
`c.push(SERVER_QUIT)
`
180
176
`asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
`
181
``
`-
s.join(timeout=TIMEOUT)
`
182
``
`-
if s.is_alive():
`
183
``
`-
self.fail("join() timed out")
`
``
177
`+
support.join_thread(s, timeout=TIMEOUT)
`
184
178
``
185
179
`self.assertEqual(c.contents, [])
`
186
180
`self.assertEqual(c.buffer, data)
`
`@@ -192,9 +186,7 @@ def test_simple_producer(self):
`
192
186
`p = asynchat.simple_producer(data+SERVER_QUIT, buffer_size=8)
`
193
187
`c.push_with_producer(p)
`
194
188
`asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
`
195
``
`-
s.join(timeout=TIMEOUT)
`
196
``
`-
if s.is_alive():
`
197
``
`-
self.fail("join() timed out")
`
``
189
`+
support.join_thread(s, timeout=TIMEOUT)
`
198
190
``
199
191
`self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
`
200
192
``
`@@ -204,9 +196,7 @@ def test_string_producer(self):
`
204
196
`data = b"hello world\nI'm not dead yet!\n"
`
205
197
`c.push_with_producer(data+SERVER_QUIT)
`
206
198
`asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
`
207
``
`-
s.join(timeout=TIMEOUT)
`
208
``
`-
if s.is_alive():
`
209
``
`-
self.fail("join() timed out")
`
``
199
`+
support.join_thread(s, timeout=TIMEOUT)
`
210
200
``
211
201
`self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
`
212
202
``
`@@ -217,9 +207,7 @@ def test_empty_line(self):
`
217
207
`c.push(b"hello world\n\nI'm not dead yet!\n")
`
218
208
`c.push(SERVER_QUIT)
`
219
209
`asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
`
220
``
`-
s.join(timeout=TIMEOUT)
`
221
``
`-
if s.is_alive():
`
222
``
`-
self.fail("join() timed out")
`
``
210
`+
support.join_thread(s, timeout=TIMEOUT)
`
223
211
``
224
212
`self.assertEqual(c.contents,
`
225
213
` [b"hello world", b"", b"I'm not dead yet!"])
`
`@@ -238,9 +226,7 @@ def test_close_when_done(self):
`
238
226
`# where the server echoes all of its data before we can check that it
`
239
227
`# got any down below.
`
240
228
`s.start_resend_event.set()
`
241
``
`-
s.join(timeout=TIMEOUT)
`
242
``
`-
if s.is_alive():
`
243
``
`-
self.fail("join() timed out")
`
``
229
`+
support.join_thread(s, timeout=TIMEOUT)
`
244
230
``
245
231
`self.assertEqual(c.contents, [])
`
246
232
`# the server might have been able to send a byte or two back, but this
`
`@@ -261,7 +247,7 @@ def test_push(self):
`
261
247
`self.assertRaises(TypeError, c.push, 'unicode')
`
262
248
`c.push(SERVER_QUIT)
`
263
249
`asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
`
264
``
`-
s.join(timeout=TIMEOUT)
`
``
250
`+
support.join_thread(s, timeout=TIMEOUT)
`
265
251
`self.assertEqual(c.contents, [b'bytes', b'bytes', b'bytes'])
`
266
252
``
267
253
``