Skip to content

No results obtained if interating a second time on the same cursor with a limit #42

@shnups

Description

@shnups

This code snippet:

import logging

from appnexus import Campaign, connect

connect('XXXXXXXXXX', 'XXXXXXXXXX')

def gather(cursor):
    print("----------")
    print("Cursor.before:\tskip={}, limit={}, len={}, size={}" \
        .format(cursor._skip, cursor._limit, len(cursor), cursor.size()))

    results = [res for res in cursor]   

    print("Results ({}):\t{}".format(len(results), ','.join([str(r.id) for r in results])))
    print("Cursor.after:\tskip={}, limit={}, len={}, size={}" \
        .format(cursor._skip, cursor._limit, len(cursor), cursor.size()))

cursor = Campaign.find(advertiser_id=XXXXXXXXXX)
cursor.limit(50)
gather(cursor)
gather(cursor)

will output the following:

----------
Cursor.before:  skip=0, limit=50, len=228, size=50
Results (50):   XXXXXXXXXX, XXXXXXXXXX,...(redacted)...,XXXXXXXXXX,XXXXXXXXXX
Cursor.after:   skip=0, limit=50, len=228, size=50
----------
Cursor.before:  skip=0, limit=50, len=228, size=50
Results (0):
Cursor.after:   skip=0, limit=50, len=228, size=50

The cursor should be usable as many time as needed and should, if all things equal on AppNexus side (accessing objects that didn't changed in the meantime), retrieve the same output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions