mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	Merge 3.4 (asyncio doc)
This commit is contained in:
		
						commit
						cbbdfb5933
					
				
					 2 changed files with 36 additions and 33 deletions
				
			
		|  | @ -310,6 +310,9 @@ Queue | ||||||
|    be interrupted between calling :meth:`qsize` and doing an operation on the |    be interrupted between calling :meth:`qsize` and doing an operation on the | ||||||
|    Queue. |    Queue. | ||||||
| 
 | 
 | ||||||
|  |    .. versionchanged:: 3.4.3 | ||||||
|  |       New :meth:`join` and :meth:`task_done` methods. | ||||||
|  | 
 | ||||||
|    .. method:: empty() |    .. method:: empty() | ||||||
| 
 | 
 | ||||||
|       Return ``True`` if the queue is empty, ``False`` otherwise. |       Return ``True`` if the queue is empty, ``False`` otherwise. | ||||||
|  | @ -341,6 +344,20 @@ Queue | ||||||
|       Return an item if one is immediately available, else raise |       Return an item if one is immediately available, else raise | ||||||
|       :exc:`QueueEmpty`. |       :exc:`QueueEmpty`. | ||||||
| 
 | 
 | ||||||
|  |    .. coroutinemethod:: join() | ||||||
|  | 
 | ||||||
|  |       Block until all items in the queue have been gotten and processed. | ||||||
|  | 
 | ||||||
|  |       The count of unfinished tasks goes up whenever an item is added to the | ||||||
|  |       queue. The count goes down whenever a consumer thread calls | ||||||
|  |       :meth:`task_done` to indicate that the item was retrieved and all work on | ||||||
|  |       it is complete.  When the count of unfinished tasks drops to zero, | ||||||
|  |       :meth:`join` unblocks. | ||||||
|  | 
 | ||||||
|  |       This method is a :ref:`coroutine <coroutine>`. | ||||||
|  | 
 | ||||||
|  |       .. versionadded:: 3.4.3 | ||||||
|  | 
 | ||||||
|    .. coroutinemethod:: put(item) |    .. coroutinemethod:: put(item) | ||||||
| 
 | 
 | ||||||
|       Put an item into the queue. If the queue is full, wait until a free slot |       Put an item into the queue. If the queue is full, wait until a free slot | ||||||
|  | @ -362,6 +379,23 @@ Queue | ||||||
| 
 | 
 | ||||||
|       Number of items in the queue. |       Number of items in the queue. | ||||||
| 
 | 
 | ||||||
|  |    .. method:: task_done() | ||||||
|  | 
 | ||||||
|  |       Indicate that a formerly enqueued task is complete. | ||||||
|  | 
 | ||||||
|  |       Used by queue consumers. For each :meth:`~Queue.get` used to fetch a task, a | ||||||
|  |       subsequent call to :meth:`task_done` tells the queue that the processing | ||||||
|  |       on the task is complete. | ||||||
|  | 
 | ||||||
|  |       If a :meth:`join` is currently blocking, it will resume when all items | ||||||
|  |       have been processed (meaning that a :meth:`task_done` call was received | ||||||
|  |       for every item that had been :meth:`~Queue.put` into the queue). | ||||||
|  | 
 | ||||||
|  |       Raises :exc:`ValueError` if called more times than there were items | ||||||
|  |       placed in the queue. | ||||||
|  | 
 | ||||||
|  |       .. versionadded:: 3.4.3 | ||||||
|  | 
 | ||||||
|    .. attribute:: maxsize |    .. attribute:: maxsize | ||||||
| 
 | 
 | ||||||
|       Number of items allowed in the queue. |       Number of items allowed in the queue. | ||||||
|  | @ -392,35 +426,9 @@ JoinableQueue | ||||||
| 
 | 
 | ||||||
| .. class:: JoinableQueue | .. class:: JoinableQueue | ||||||
| 
 | 
 | ||||||
|    A subclass of :class:`Queue` with :meth:`task_done` and :meth:`join` |    Deprecated alias for :class:`Queue`. | ||||||
|    methods. |  | ||||||
| 
 | 
 | ||||||
|    .. coroutinemethod:: join() |    .. deprecated:: 3.4.3 | ||||||
| 
 |  | ||||||
|       Block until all items in the queue have been gotten and processed. |  | ||||||
| 
 |  | ||||||
|       The count of unfinished tasks goes up whenever an item is added to the |  | ||||||
|       queue. The count goes down whenever a consumer thread calls |  | ||||||
|       :meth:`task_done` to indicate that the item was retrieved and all work on |  | ||||||
|       it is complete.  When the count of unfinished tasks drops to zero, |  | ||||||
|       :meth:`join` unblocks. |  | ||||||
| 
 |  | ||||||
|       This method is a :ref:`coroutine <coroutine>`. |  | ||||||
| 
 |  | ||||||
|    .. method:: task_done() |  | ||||||
| 
 |  | ||||||
|       Indicate that a formerly enqueued task is complete. |  | ||||||
| 
 |  | ||||||
|       Used by queue consumers. For each :meth:`~Queue.get` used to fetch a task, a |  | ||||||
|       subsequent call to :meth:`task_done` tells the queue that the processing |  | ||||||
|       on the task is complete. |  | ||||||
| 
 |  | ||||||
|       If a :meth:`join` is currently blocking, it will resume when all items |  | ||||||
|       have been processed (meaning that a :meth:`task_done` call was received |  | ||||||
|       for every item that had been :meth:`~Queue.put` into the queue). |  | ||||||
| 
 |  | ||||||
|       Raises :exc:`ValueError` if called more times than there were items |  | ||||||
|       placed in the queue. |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| Exceptions | Exceptions | ||||||
|  |  | ||||||
|  | @ -148,17 +148,12 @@ def run(self): | ||||||
| class PyCoroutineMixin(object): | class PyCoroutineMixin(object): | ||||||
|     def handle_signature(self, sig, signode): |     def handle_signature(self, sig, signode): | ||||||
|         ret = super(PyCoroutineMixin, self).handle_signature(sig, signode) |         ret = super(PyCoroutineMixin, self).handle_signature(sig, signode) | ||||||
| #        signode.insert(0, addnodes.desc_addname('coroutine ', 'coroutine ')) |  | ||||||
|         signode.insert(0, addnodes.desc_annotation('coroutine ', 'coroutine ')) |         signode.insert(0, addnodes.desc_annotation('coroutine ', 'coroutine ')) | ||||||
|         return ret |         return ret | ||||||
| 
 | 
 | ||||||
|     def needs_arglist(self): |  | ||||||
|         return False |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| class PyCoroutineFunction(PyCoroutineMixin, PyModulelevel): | class PyCoroutineFunction(PyCoroutineMixin, PyModulelevel): | ||||||
|     def run(self): |     def run(self): | ||||||
|         # a decorator function is a function after all |  | ||||||
|         self.name = 'py:function' |         self.name = 'py:function' | ||||||
|         return PyModulelevel.run(self) |         return PyModulelevel.run(self) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Victor Stinner
						Victor Stinner