changeset: 74970:bf536b46d7f2 parent: 74966:e9d01c5c92ed parent: 74969:fe5eb6d35025 user: Sandro Tosi date: Wed Feb 15 23:27:00 2012 +0100 files: Doc/library/multiprocessing.rst Lib/multiprocessing/__init__.py description: Issue #11836: document and expose multiprocessing.SimpleQueue diff -r e9d01c5c92ed -r bf536b46d7f2 Doc/library/multiprocessing.rst --- a/Doc/library/multiprocessing.rst Wed Feb 15 22:30:29 2012 +0100 +++ b/Doc/library/multiprocessing.rst Wed Feb 15 23:27:00 2012 +0100 @@ -483,7 +483,7 @@ For passing messages one can use :func:`Pipe` (for a connection between two processes) or a queue (which allows multiple producers and consumers). -The :class:`Queue` and :class:`JoinableQueue` types are multi-producer, +The :class:`Queue`, :class:`SimpleQueue` and :class:`JoinableQueue` types are multi-producer, multi-consumer FIFO queues modelled on the :class:`queue.Queue` class in the standard library. They differ in that :class:`Queue` lacks the :meth:`~queue.Queue.task_done` and :meth:`~queue.Queue.join` methods introduced @@ -629,6 +629,23 @@ exits -- see :meth:`join_thread`. +.. class:: SimpleQueue() + + It is a simplified :class:`Queue` type, very close to a locked :class:`Pipe`. + + .. method:: empty() + + Return ``True`` if the queue is empty, ``False`` otherwise. + + .. method:: get() + + Remove and return an item from the queue. + + .. method:: put(item) + + Put *item* into the queue. + + .. class:: JoinableQueue([maxsize]) :class:`JoinableQueue`, a :class:`Queue` subclass, is a queue which diff -r e9d01c5c92ed -r bf536b46d7f2 Lib/multiprocessing/__init__.py --- a/Lib/multiprocessing/__init__.py Wed Feb 15 22:30:29 2012 +0100 +++ b/Lib/multiprocessing/__init__.py Wed Feb 15 23:27:00 2012 +0100 @@ -48,7 +48,7 @@ 'Manager', 'Pipe', 'cpu_count', 'log_to_stderr', 'get_logger', 'allow_connection_pickling', 'BufferTooShort', 'TimeoutError', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Condition', - 'Event', 'Queue', 'JoinableQueue', 'Pool', 'Value', 'Array', + 'Event', 'Queue', 'SimpleQueue', 'JoinableQueue', 'Pool', 'Value', 'Array', 'RawValue', 'RawArray', 'SUBDEBUG', 'SUBWARNING', ] @@ -223,6 +223,13 @@ from multiprocessing.queues import JoinableQueue return JoinableQueue(maxsize) +def SimpleQueue(): + ''' + Returns a queue object + ''' + from multiprocessing.queues import SimpleQueue + return SimpleQueue() + def Pool(processes=None, initializer=None, initargs=(), maxtasksperchild=None): ''' Returns a process pool object

AltStyle によって変換されたページ (->オリジナル) /