def METHOD_NAME(self, max_time=None):
    """(Try to) transmit all pending records with recording timestamps
    smaller than the given time now."""
    with self.mutex:
        keys = list(self.records_queue.keys())
    keys.sort()
    max_time = max_time or time.time()
    buckets_to_send = [k for k in keys if k < max_time]
    for bucket_ts in buckets_to_send:
        # Get the records out of the queue
        with self.mutex:
            bucket_records = self.records_queue[bucket_ts]
        # Try to send the records (to signal failure, this can either
        # throw or return False, depending on how loud it wants to be).
        success = self._save_records(bucket_ts, bucket_records)
        # Only remove them from the queue if sending didn't fail
        if success is not False:
            with self.mutex:
                del self.records_queue[bucket_ts]