@sessioned
    def get_ready_streams(self, batch_size, current_time, expire=False,
                          session=None):
        q = session.query(models.Stream)
        if expire:
            states = (int(models.StreamState.active),
                      int(models.StreamState.retry_expire))
        else:
            states = (
                int(models.StreamState.active),
                int(models.StreamState.retry_fire))

        q = q.filter(models.Stream.state.in_(states))
        if expire:
            q = q.filter(models.Stream.expire_timestamp < current_time)
        else:
            q = q.filter(models.Stream.fire_timestamp < current_time)
        q = q.limit(batch_size)
        return q.all()
dataset/ETHPy150Open openstack/stacktach-winchester/winchester/db/interface.py/DBInterface.get_ready_streams/original