def waitget(self,key, maxwaittime = <NUM_LIT> ):
wtimes = [<NUM_LIT>] * <NUM_LIT:3> + [<NUM_LIT:0.5>] * <NUM_LIT:2> + [<NUM_LIT:1>]<EOL>tries = <NUM_LIT:0><EOL>waited = <NUM_LIT:0><EOL>while <NUM_LIT:1>:<EOL><INDENT>try:<EOL><INDENT>val = self[key]<EOL>return val<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>if waited > maxwaittime:<EOL><INDENT>raise KeyError(key)<EOL><DEDENT>time.sleep(wtimes[tries])<EOL>waited+=wtimes[tries]<EOL>if tries < len(wtimes) -<NUM_LIT:1>:<EOL><INDENT>tries+=<NUM_LIT:1><EOL><DEDENT><DEDENT>
Wait (poll) for a key to get a value

        Will wait for `maxwaittime` seconds before raising a KeyError.
        The call exits normally if the `key` field in db gets a value
        within the timeout period.

        Use this for synchronizing different processes or for ensuring
        that an unfortunately timed "db['key'] = newvalue" operation
        in another process (which causes all 'get' operation to cause a
        KeyError for the duration of pickling) won't screw up your program
        logic.