jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/607170 )
Change subject: [IMPR] Wait for _putthread is done in BaseBot.exit() ......................................................................
[IMPR] Wait for _putthread is done in BaseBot.exit()
For asychronous puts there is a pywikibot._putthread which holds the queue to be done. Wait in BaseBot exit() method until all asychronous put were made and write statistics after it.
Change-Id: I982a508fcdbf9806b49367800c2cf0afdc2a32bf --- M pywikibot/bot.py 1 file changed, 15 insertions(+), 7 deletions(-)
Approvals: Matěj Suchánek: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py index 1dc7855..c111c31 100644 --- a/pywikibot/bot.py +++ b/pywikibot/bot.py @@ -1289,28 +1289,36 @@ May be overridden by subclasses. """ self.teardown() + if hasattr(self, '_start_ts'): + read_delta = pywikibot.Timestamp.now() - self._start_ts + read_seconds = int(read_delta.total_seconds()) + + if pywikibot._putthread.is_alive(): + pywikibot._flush() + pywikibot.output('\n{} pages read' '\n{} pages written' '\n{} pages skipped' .format(self._treat_counter, self._save_counter, self._skip_counter)) + if hasattr(self, '_start_ts'): - delta = (pywikibot.Timestamp.now() - self._start_ts) - seconds = int(delta.total_seconds()) - if delta.days: + write_delta = pywikibot.Timestamp.now() - self._start_ts + write_seconds = int(write_delta.total_seconds()) + if write_delta.days: pywikibot.output( 'Execution time: {d.days} days, {d.seconds} seconds' - .format(d=delta)) + .format(d=write_delta)) else: pywikibot.output('Execution time: {} seconds' - .format(delta.seconds)) + .format(write_delta.seconds)) if self._treat_counter: pywikibot.output('Read operation time: {:.1f} seconds' - .format(seconds / self._treat_counter)) + .format(read_seconds / self._treat_counter)) if self._save_counter: pywikibot.output('Write operation time: {:.1f} seconds' - .format(seconds / self._save_counter)) + .format(write_seconds / self._save_counter))
# exc_info contains exception from self.run() while terminating exc_info = sys.exc_info()
pywikibot-commits@lists.wikimedia.org