#NEWLINE# def get( self , block = True , timeout = None ) : #NEWLINE# #INDENT# 'Remove and return an item from the queue.\n\n        If optional args `block` is True and `timeout` is None (the default),\n        block if necessary until an item is available. If `timeout` is a\n        positive number, it blocks at most `timeout` seconds and raises the\n        Empty exception if no item was available within that time. Otherwise\n        (`block` is False), return an item if one is immediately available,\n        else raise the Empty exception (`timeout` is ignored in that case).\n        ' #NEWLINE# self . not_empty . acquire ( ) #NEWLINE# try : #NEWLINE# #INDENT# if ( not block ) : #NEWLINE# #INDENT# if ( not self . _qsize ( ) ) : #NEWLINE# #INDENT# raise Empty #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( timeout is None ) : #NEWLINE# #INDENT# while ( not self . _qsize ( ) ) : #NEWLINE# #INDENT# self . not_empty . wait ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( timeout < 0 ) : #NEWLINE# #INDENT# raise ValueError ( "'timeout' must be a positive number" ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# endtime = ( _time ( ) + timeout ) #NEWLINE# while ( not self . _qsize ( ) ) : #NEWLINE# #INDENT# remaining = ( endtime - _time ( ) ) #NEWLINE# if ( remaining <= 0.0 ) : #NEWLINE# #INDENT# raise Empty #NEWLINE# #UNINDENT# self . not_empty . wait ( remaining ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# item = self . _get ( ) #NEWLINE# self . not_full . notify ( ) #NEWLINE# return item #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# self . not_empty . release ( )