Page MenuHomePhabricator

Make api.APIGenerator a Generator
Closed, ResolvedPublicFeature

Description

Feature summary:

api.APIGenerator should be a Generator as the class name says

Use case(s) :

Currenly all api generators are Iterables; they work with for loops but it doest not support next() function of an Iterator but this is used a couple o times: see here.

This also solves T301318.

Benefits:

Making api generators a collections.abc.Generator they are capable to be used as

  • Iterable (for loops etc.)
  • Iterator (next() function etc.)
  • Generator (close() method which is used by BaseBot; BaseBot tries to convert every Iterable to a Generator)

Event Timeline

Xqt renamed this task from Make api.APIGenerator a generator to Make api.APIGenerator a Generator.Jul 8 2022, 2:47 PM
Xqt triaged this task as Low priority.
Xqt updated the task description. (Show Details)

Change 812372 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [IMPR] Make all api generators a collections.abc.Generator

https://gerrit.wikimedia.org/r/812372

Change 812372 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] Provide a Generator wrapper class to start/restart a generator

https://gerrit.wikimedia.org/r/812372