I've built some report tools using Pywikibot. As things are growing it now takes up to 2 hours to finish the reports so I'm looking to speed things up. Main ideas:
page.get(throttle=False)
handles thisUnfortunately I can't find much documentation about caching and db access. Only way seems to dive into the code, and well, there's limited information about database access in user-config.py
. If there is any, where can I find good documentation about pywikibot caching and direct db access?
And, are there other ways to speed things up?
Use PreloadingGenerator
so that pages are loaded in batches. Or MySQLPageGenerator
if you use direct DB access.
See examples here.
I'm using "-pt:1" option in the command to make one edit per second.
I'm currently running the command
python pwb.py category add -pt:1 -file:WX350.txt -to:"Taken with Sony DSC-WX350"
https://www.mediawiki.org/wiki/Manual:Pywikibot/Global_Options
Looks like pagegenerators
is indeed a good way to speed up things. The best documentation for that is directly in the source.
Even in there it's not directly clear where to put the MySQL connection details. (Will update this hopefully.)
- Disable throttling, the script is read-only, so page.get(throttle=False) handles this
"throttle" parameter of Page.get() is not supported since Pywikibot 2.0 (formerly known as rewrite) and was removed in 5.0.0. Pywikibot 2.0+ has not activated a get throttle by default. Decreasing putthrottle is only for putting a page to the wiki and may be restricted by local policies. Never touch maxlag parameter which is server related.
If you are using multiple sites the first run needs a lot of time until all site objects are cached. PreloadingGenerator can be be used for bulk load of page contents but decreases speed if meta data are required only. In summary speeding up your script depends on you implementation and your need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With