#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\n        a positive number, it blocks at most 'timeout' seconds and raises\n        the Empty exception if no item was available within that time.\n        Otherwise ('block' is false), return an item if one is immediately\n        available, else raise the Empty exception ('timeout' is ignored\n        in that case).\n        " #NEWLINE# self . not_empty . acquire ( ) #NEWLINE# try : #NEWLINE# #INDENT# if ( not block ) : #NEWLINE# #INDENT# if self . _empty ( ) : #NEWLINE# #INDENT# raise Empty #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( timeout is None ) : #NEWLINE# #INDENT# while self . _empty ( ) : #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# endtime = ( _time ( ) + endtime ) #NEWLINE# while self . _empty ( ) : #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# item = self . _get ( ) #NEWLINE# self . not_full . notify ( ) #NEWLINE# return item #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# self . not_empty . release ( )