[Python-Dev] Obtaining stack-frames from co-routine objects

MRAB python at mrabarnett.plus.com
Sat Jun 13 21:01:57 CEST 2015


On 2015-06-13 11:38, jaivish kothari wrote:
> Hi ,
>
>     I had a Question,i hope i'll find the solution here.
>
> Say i have a Queue.
>   >>> h = Queue.Queue(maxsize=0)
>  >>> h.put(1)
>  >>> h.put(2)
>  >>> h.empty()
> False
>  >>> h.join()
>  >>> h.empty()
> False
>  >>> h.get()
> 1
>  >>> h.get()
> 2
>  >>> h.get()
> Blocked.......................
>
> My Question is :
> In a single threaded environment why does the get() gets blocked ,
> instead of raising an exception.On interpreter i have no way to resume
> working.
>
> And my second question is :
> Why doe we have to explicitly call task_done after get(). why doesn't
> get() implicitly call task_done().
> as for put() entry for unfinished_task is automatically added .why not
> get deleted in get() then.
>
The way it's used is to get a item, process it, and then signal that it
has finished with it. There's going to be a period of time when an item
is not in the queue, but is still being processed.



More information about the Python-Dev mailing list