#NEWLINE# @ synchronizedDeferred ( lock ) #NEWLINE# @ deferredAsThread #NEWLINE# def getprime( self ) : #NEWLINE# #INDENT# pfh = open ( config . DRONED_PRIMES ) #NEWLINE# psize = os . stat ( config . DRONED_PRIMES ) [ 6 ] #NEWLINE# if ( ( ( psize % 4 ) != 0 ) or ( psize < 4000 ) ) : #NEWLINE# #INDENT# pfh . close ( ) #NEWLINE# raise AssertionError ( 'primes file is corrupt/too small' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# fcntl . fcntl ( pfh . fileno ( ) , fcntl . F_SETFD , fcntl . FD_CLOEXEC ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# result = 0 #NEWLINE# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# r = ( random . randint ( 0 , ( ( psize - 4 ) / 4 ) ) * 4 ) #NEWLINE# pfh . seek ( r ) #NEWLINE# p = pfh . read ( 4 ) #NEWLINE# prime = struct . unpack ( '!L' , p ) [ 0 ] #NEWLINE# sync = synchronizedInThread ( ) #NEWLINE# trp = sync ( self . _trackPrime ) #NEWLINE# result = trp ( prime ) #NEWLINE# break #NEWLINE# #UNINDENT# except AssertionError : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# pfh . close ( ) #NEWLINE# return result