microsoftgraph / microsoftgraph/msgraph-sdk-python-core

Unclear how to resume iterating with `PageIterator` if the callback returns `False`

Open
#688 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority:p2
Dominant language
Python
Stars
288
Forks
52
Avg merge
8h 10m
Merged PRs (30d)
1

Description

In other SDKs, the iterator class typically has a Resume method to restart the iteration where it left off, and a corresponding State property to check if the iterator has completed or not. For example, in .NET:

var pageIterator = PageIterator<Message, MessageCollectionResponse>
    .CreatePageIterator(
        graphClient,
        messages,
        (msg) =>
        {
            Console.WriteLine(msg.Subject);
            count++;
            // If we've iterated over the limit,
            // stop the iteration by returning false
            return count < pauseAfter;
        });

await pageIterator.IterateAsync();

while (pageIterator.State != PagingState.Complete)
{
    Console.WriteLine("Iteration paused for 5 seconds...");
    await Task.Delay(5000);
    // Reset count
    count = 0;
    await pageIterator.ResumeAsync();
}

Is there a way to do this in this SDK?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the PageIterator implementation and its callback handling, then compare the requested behavior with the .NET example in the issue. Determine how a paused iteration could expose completion state and resume from its current position; done means the SDK behavior and its usage are clearly defined and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.