Page MenuHomePhabricator

tools.ThreadList.stop_all() leads to AttributeError
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce:

  • Add self.threads.stop_all() to weblinkchecker.py e.g. within this at in line 623 before the break statement.
  • run pwb weblinkchecker -simulate -cat:Neapel

What happens?:

The script fails with AttributeError because a threading.Thread does not have a` stop()` method

    self.exit()
  File "C:\pwb\GIT\core\pywikibot\bot.py", line 1484, in exit
    self.teardown()
  File ".\scripts\weblinkchecker.py", line 623, in teardown
    self.threads.stop_all()
  File "C:\pwb\GIT\core\pywikibot\tools\__init__.py", line 818, in stop_all
    thd.stop()
AttributeError: 'LinkCheckThread' object has no attribute 'stop'. Did you mean: '_stop'?
CRITICAL: Exiting due to uncaught exception <class 'AttributeError'>

Software version:
introduced with rPWBC4d756b3

Event Timeline

Xqt triaged this task as Medium priority.
Xqt added subscribers: Mpaa, jayvdb.

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

[pywikibot/core@master] [bugfix] Remove ThreadList.stop_all() method

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

@Mpaa: I am unsure how to proceed. We could

  • keep the current implementation and add a warning to our documentation that the Thread object hast to be sublassed and provide a stop method if stop_all() is to be used (like ThreadedGenerator does)
  • remove the stop_all method and stopping must be implemented outside the ThreadList class
  • ignore AttributeError in stop_all() method and just write a debug message (and add a warning to our documentation)

What do you suggest here?

@Mpaa: I am unsure how to proceed. We could

  • keep the current implementation and add a warning to our documentation that the Thread object hast to be sublassed and provide a stop method if stop_all() is to be used (like ThreadedGenerator does)
  • remove the stop_all method and stopping must be implemented outside the ThreadList class
  • ignore AttributeError in stop_all() method and just write a debug message (and add a warning to our documentation)

What do you suggest here?

I agree with remove the stop_all method

Change 789893 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Remove ThreadList.stop_all() method

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