If I run MySQL page generator for longer time (here is the example of cca 1.5 day long run), it goes all the way through the retrieved list of pages and after bot.run() ends, bot throws the following error on toolforge (and therefore does not continue with the code following after bot.run()):
422844 pages read 0 pages written Execution time: 1 days, 33969 seconds Read operation time: 0 seconds Script terminated by exception: ERROR: AttributeError: 'NoneType' object has no attribute 'close' Traceback (most recent call last): File "pwb.py", line 257, in <module> if not main(): File "pwb.py", line 250, in main run_python_file(filename, [filename] + args, argvu, file_package) File "pwb.py", line 119, in run_python_file main_mod.__dict__) File "./nepodporovane-parametry-infoboxu.py", line 290, in <module> main() File "./nepodporovane-parametry-infoboxu.py", line 277, in main bot2.run() # guess what it does File "/mnt/nfs/labstore-secondary-tools-project/pywikibot/public_html/core/pywikibot/bot.py", line 1479, in run for item in self.generator: File "/mnt/nfs/labstore-secondary-tools-project/pywikibot/public_html/core/pywikibot/pagegenerators.py", line 2777, in MySQLPageGenerator for row in row_gen: File "/mnt/nfs/labstore-secondary-tools-project/pywikibot/public_html/core/pywikibot/data/mysql.py", line 100, in mysql_query conn.close() File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 734, in close sock.close() AttributeError: 'NoneType' object has no attribute 'close' CRITICAL: Exiting due to uncaught exception <class 'AttributeError'>
If I run it for a shorter time period, it works as expected, therefore it seems to me the connection to the database is lost? Or closed automatically after some amount of time? And it is closed by the database, pywikibot or pymysql?
The code looks simply like:
gen = pagegenerators.MySQLPageGenerator('select page_namespace, page_title from page where page_namespace like 0 and not page_is_redirect order by page_title') bot = BasicBot(gen, **options) bot.run() page = pywikibot.Page(bot.site, 'Wikipedie:Údržbové seznamy/Nepodporované parametry infoboxů/seznam') page.text += bot.list page.save(summary='Robot: ' + bot.summary) return True