Commit Graph

29 Commits

Author SHA1 Message Date
Raymond Hettinger 9e1bc982ff Add queues will alternative fetch orders (priority based and stack based). 2008-01-16 23:40:45 +00:00
Raymond Hettinger f59e962b49 Refactor if/elif chain for clarity and speed. Remove dependency on subclasses having to implement _empty and _full. 2008-01-15 20:52:42 +00:00
Raymond Hettinger a3c77677ca ... and the number of the counting shall be three. 2006-11-23 21:35:19 +00:00
Skip Montanaro 86116e2b75 document the class, not its initializer 2006-06-10 14:09:11 +00:00
Raymond Hettinger c4e94b90a8 Don't decrement below zero. And add more tests. 2006-03-25 12:15:04 +00:00
Tim Peters e33901eb2b Whitespace normalization. 2006-03-25 01:50:43 +00:00
Raymond Hettinger fd3fcf0b35 SF Patch #1455676: Simplify using Queues with daemon consumer threads
Adds join() and task_done() methods to track when all enqueued tasks have
been gotten and fully processed by daemon consumer threads.
2006-03-24 20:43:29 +00:00
Tim Peters 71ed2201e2 Simplified the new get/get_nowait/put/put_nowait implementations a bit. 2004-07-12 01:20:32 +00:00
Tim Peters 5af0e41482 Bug #788520: Queue class has logic error when non-blocking
I don't agree it had a bug (see the report), so this is *not* a candidate
for backporting, but the docs were confusing and the Queue implementation
was old enough to vote.

Rewrote put/put_nowait/get/get_nowait from scratch, to use a pair of
Conditions (not_full and not_empty), sharing a common mutex.  The code
is 1/4 the size now, and 6.25x easier to understand.  For blocking
with timeout, we also get to reuse (indirectly) the tedious timeout
code from threading.Condition.  The Full and Empty exceptions raised
by non-blocking calls are now easy (instead of nearly impossible) to
explain truthfully:  Full is raised if and only if the Queue truly
is full when the non-blocking put call checks the queue size, and
similarly for Empty versus non-blocking get.

What I don't know is whether the new implementation is slower (or
faster) than the old one.  I don't really care.  Anyone who cares
a lot is encouraged to check that.
2004-07-12 00:45:14 +00:00
Raymond Hettinger 756b3f3c15 * Move collections.deque() in from the sandbox
* Add unittests, newsitem, and whatsnew
* Apply to Queue.py mutex.py threading.py pydoc.py and shlex.py
* Docs are forthcoming
2004-01-29 06:37:52 +00:00
Brett Cannon b42bb5a88a Add __all__ . 2003-07-01 05:34:27 +00:00
Guido van Rossum a0934246d3 Use the dummy_thread module in Queue.py and tempfile.py.
tempfile.py already contained code to let it run without threads present;
for Queue.py this is considered a useful feature too.
2002-12-30 22:36:09 +00:00
Martin v. Löwis 77ac429eff Patch #572628: Optional timeouts for put and get. 2002-10-15 15:11:13 +00:00
Raymond Hettinger 46ac8eb3c8 Code modernization. Replace v=s[i]; del s[i] with single lookup v=s.pop(i) 2002-06-30 03:39:14 +00:00
Mark Hammond 3b959dbcaf Fix bug 544473 - "Queue module can deadlock".
Use try/finally to ensure all Queue locks remain stable.
Includes test case.  Bugfix candidate.
2002-04-19 00:11:32 +00:00
Skip Montanaro 78349072f7 removed __all__ from several modules 2001-02-18 03:30:53 +00:00
Skip Montanaro e99d5ea25b added __all__ lists to a number of Python modules
added test script and expected output file as well
this closes patch 103297.
__all__ attributes will be added to other modules without first submitting
a patch, just adding the necessary line to the test script to verify
more-or-less correct implementation.
2001-01-20 19:54:20 +00:00
Tim Peters b8c941771a Variant of Skip's patch 103246 (Remove unneeded string exception compat from Queue). 2001-01-15 22:53:46 +00:00
Jeremy Hylton a05e293a21 typos fixed by Rob Hooft 2000-06-28 14:48:01 +00:00
Guido van Rossum 4acc25bd39 Mass patch by Ka-Ping Yee:
1. Comments at the beginning of the module, before
       functions, and before classes have been turned
       into docstrings.

    2. Tabs are normalized to four spaces.

Also, removed the "remove" function from dircmp.py, which reimplements
list.remove() (it must have been very old).
2000-02-02 15:10:15 +00:00
Guido van Rossum a41c691371 Make the maxsize constructor argument default to 0 (an unlimited queue size). 1999-09-09 14:54:28 +00:00
Guido van Rossum 9e1721fa79 Tim Peters:
+ Implements a put_nowait method.
+ Adds a corresponding Queue.Full exception.
+ Simplifies the implementation by adding optional "block" args to get() and
put(), and makes the old get_nowait() and new put_nowait() one-line
redirections to get() and put().
+ Uses (much) simpler logic for the nowait cases.
+ Regularizes the doc strings to something closer to "Guido style" <wink>.
+ Converts two stray tabs into spaces.
+ Removes confusing verbiage about the queue "not being available" from the
docstrings -- never knew what that meant as a user, and after digging into
the implementation still didn't know what it was trying to say.
1999-02-08 18:34:01 +00:00
Guido van Rossum 7e6d18c1c0 Replace all calls to acquire_lock() and release_lock() with acquire()
and release() instead.
1998-04-29 14:29:32 +00:00
Guido van Rossum c09e6b1c0a Clarify that put *blocks* when the queue is full. Add some blank
lines to doc strings.
1998-04-09 14:25:32 +00:00
Guido van Rossum 45e2fbc2e7 Mass check-in after untabifying all files that need it. 1998-03-26 21:13:24 +00:00
Barry Warsaw 3d96d522ec (Queue.Empty): When class based exceptions are in force, derive this
class from the standard base exception Exception.  Otherwise define
Queue.Empty as a string exception.

(Queue): 8-space to 4-space indentation conversion.  Also, basically
recast all method comments into docstrings.
1997-11-20 19:56:38 +00:00
Guido van Rossum dd8cb446e1 Some minute changes. 1993-12-29 15:33:08 +00:00
Guido van Rossum 7bc817d5ba * Mass change: get rid of all init() methods, in favor of __init__()
constructors.  There is no backward compatibility.  Not everything has
  been tested.
* aiff.{py,doc}: deleted in favor of aifc.py (which contains its docs as
  comments)
1993-12-17 15:25:27 +00:00
Guido van Rossum 9022fceae8 New module implementing a multi-everything queue. 1992-08-25 12:30:44 +00:00