jenkins-bot has submitted this change and it was merged.
Change subject: Do not repeat the login process ......................................................................
Do not repeat the login process
Log calls to site.login when loginstatus is IN_PROGRESS. If site.logged_in() is True, set the loginstatus and do not re-attempt to log in.
Change-Id: Icb4c717201c661eed8d4a13eeaf2bbfb1f58aef0 --- M pywikibot/site.py 1 file changed, 20 insertions(+), 0 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index 385ed16..cd2a41d 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -743,6 +743,26 @@
def login(self, sysop=False): """Log the user in if not already logged in.""" + # TODO: this should include an assert that loginstatus + # is not already IN_PROGRESS, however the + # login status may be left 'IN_PROGRESS' because + # of exceptions or if the first method of login + # (below) is successful. Instead, log the problem, + # to be increased to 'warning' level once majority + # of issues are resolved. + if self._loginstatus == LoginStatus.IN_PROGRESS: + pywikibot.log( + u'%r.login(%r) called when a previous login was in progress.' + % (self, sysop) + ) + # There are several ways that the site may already be + # logged in, and we do not need to hit the server again. + # logged_in() is False if _userinfo exists, which means this + # will have no effect for the invocation from api.py + if self.logged_in(sysop): + self._loginstatus = (LoginStatus.AS_SYSOP + if sysop else LoginStatus.AS_USER) + return # check whether a login cookie already exists for this user self._loginstatus = LoginStatus.IN_PROGRESS if hasattr(self, "_userinfo"):
pywikibot-commits@lists.wikimedia.org