Skip to content

Commit a037bda

Browse files
ShaharNavehyouknowone
authored andcommitted
Update queue from 3.14.2
1 parent 0dcc975 commit a037bda

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

Lib/queue.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ def task_done(self):
8080
have been processed (meaning that a task_done() call was received
8181
for every item that had been put() into the queue).
8282
83-
shutdown(immediate=True) calls task_done() for each remaining item in
84-
the queue.
85-
8683
Raises a ValueError if called more times than there were items
8784
placed in the queue.
8885
'''
@@ -239,9 +236,11 @@ def shutdown(self, immediate=False):
239236
By default, gets will only raise once the queue is empty. Set
240237
'immediate' to True to make gets raise immediately instead.
241238
242-
All blocked callers of put() and get() will be unblocked. If
243-
'immediate', a task is marked as done for each item remaining in
244-
the queue, which may unblock callers of join().
239+
All blocked callers of put() and get() will be unblocked.
240+
241+
If 'immediate', the queue is drained and unfinished tasks
242+
is reduced by the number of drained tasks. If unfinished tasks
243+
is reduced to zero, callers of Queue.join are unblocked.
245244
'''
246245
with self.mutex:
247246
self.is_shutdown = True

Lib/test/test_queue.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
# to ensure the Queue locks remain stable.
33
import itertools
44
import random
5-
import sys
65
import threading
76
import time
87
import unittest
98
import weakref
10-
from test.support import gc_collect
9+
from test.support import gc_collect, bigmemtest
1110
from test.support import import_helper
1211
from test.support import threading_helper
1312

@@ -964,33 +963,33 @@ def test_order(self):
964963
# One producer, one consumer => results appended in well-defined order
965964
self.assertEqual(results, inputs)
966965

967-
def test_many_threads(self):
966+
@bigmemtest(size=50, memuse=100*2**20, dry_run=False)
967+
def test_many_threads(self, size):
968968
# Test multiple concurrent put() and get()
969-
N = 50
970969
q = self.q
971970
inputs = list(range(10000))
972-
results = self.run_threads(N, q, inputs, self.feed, self.consume)
971+
results = self.run_threads(size, q, inputs, self.feed, self.consume)
973972

974973
# Multiple consumers without synchronization append the
975974
# results in random order
976975
self.assertEqual(sorted(results), inputs)
977976

978-
def test_many_threads_nonblock(self):
977+
@bigmemtest(size=50, memuse=100*2**20, dry_run=False)
978+
def test_many_threads_nonblock(self, size):
979979
# Test multiple concurrent put() and get(block=False)
980-
N = 50
981980
q = self.q
982981
inputs = list(range(10000))
983-
results = self.run_threads(N, q, inputs,
982+
results = self.run_threads(size, q, inputs,
984983
self.feed, self.consume_nonblock)
985984

986985
self.assertEqual(sorted(results), inputs)
987986

988-
def test_many_threads_timeout(self):
987+
@bigmemtest(size=50, memuse=100*2**20, dry_run=False)
988+
def test_many_threads_timeout(self, size):
989989
# Test multiple concurrent put() and get(timeout=...)
990-
N = 50
991990
q = self.q
992991
inputs = list(range(1000))
993-
results = self.run_threads(N, q, inputs,
992+
results = self.run_threads(size, q, inputs,
994993
self.feed, self.consume_timeout)
995994

996995
self.assertEqual(sorted(results), inputs)

0 commit comments

Comments
 (0)