def delay(self, params, now=None):
if now is None:<EOL><INDENT>now = time.time()<EOL><DEDENT>if not self.last:<EOL><INDENT>self.last = now<EOL><DEDENT>elif now < self.last:<EOL><INDENT>now = self.last<EOL><DEDENT>leaked = now - self.last<EOL>self.last = now<EOL>self.level = max(self.level - leaked, <NUM_LIT:0>)<EOL>difference = self.level + self.limit.cost - self.limit.unit_value<EOL>if difference >= self.eps:<EOL><INDENT>self.next = now + difference<EOL>return difference<EOL><DEDENT>self.level += self.limit.cost<EOL>self.next = now<EOL>return None<EOL>
Determine delay until next request.