@synchronizedDeferred(lock)
    @deferredAsThread #will catch exceptions
    def getprime(self):
        pfh = open(config.DRONED_PRIMES)
        psize = os.stat(config.DRONED_PRIMES)[6]
        if (psize % 4) != 0 or psize < 4000:
            pfh.close()
            raise AssertionError("primes file is corrupt/too small")
        try: fcntl.fcntl(pfh.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC)
        except: pass
        result = 0
        while True:
            try:
                r = random.randint(0,(psize - 4) / 4) * 4
                pfh.seek(r)
                p = pfh.read(4)
                prime = struct.unpack("!L",p)[0]
                #makes a blocking call from this thread to the reactor
                #this is done for thread safety
                sync = synchronizedInThread()
                trp = sync(self._trackPrime)
                result = trp(prime) 
                break
            except __HOLE__: continue
        pfh.close()
        return result
dataset/ETHPy150Open OrbitzWorldwide/droned/droned/lib/droned/models/server.py/DroneServer.getprime