(self)
Polls the 'initialized' flag to be set by the started Thread in run().
Polls the 'initialized' flag to be set by the started Thread in run().
Polls the initialized flag to be set by the started Thread in run () .
def _wait_for_initialization(self):
        """
        Polls the 'initialized' flag to be set by the started Thread in run().
        """
        # A race condition may occur without waiting for initialization:
        # __init__() finishes with the start() call, but the Thread needs some time to actually start working.
        # If opening the database file fails in run(), an exception will occur and self.exception will be set.
        # But if we run check_raise_error() before run() had a chance to set self.exception, it will report
        # a false negative: An exception occured and the thread terminates but self.exception is unset.
        # This leads to a deadlock while waiting for the results of execute().
        # By waiting for the Thread to set the initialized flag, we can ensure the thread has successfully
        # opened the file - and possibly set self.exception to be detected by check_raise_error().

        start_time = time.time()
        while time.time() - start_time < self.timeout:
            if self._sqlitedict_thread_initialized or self.exception:
                return
            time.sleep(0.1)
        raise TimeoutError("SqliteMultithread failed to flag initialization withing %0.0f seconds." % self.timeout)
def _wait_for_initialization ( self ) : # A race condition may occur without waiting for initialization: # __init__() finishes with the start() call, but the Thread needs some time to actually start working. # If opening the database file fails in run(), an exception will occur and self.exception will be set. # But if we run check_raise_error() before run() had a chance to set self.exception, it will report # a false negative: An exception occured and the thread terminates but self.exception is unset. # This leads to a deadlock while waiting for the results of execute(). # By waiting for the Thread to set the initialized flag, we can ensure the thread has successfully # opened the file - and possibly set self.exception to be detected by check_raise_error(). start_time = time . time ( ) while time . time ( ) - start_time < self . timeout : if self . _sqlitedict_thread_initialized or self . exception : return time . sleep ( 0.1 ) raise TimeoutError ( "SqliteMultithread failed to flag initialization withing %0.0f seconds." % self . timeout )