Page MenuHomePhabricator

pywikibot can't write log file after size >1MB
Closed, DuplicatePublic

Description

Normally pywikibot writes logs for all scripts.
script-bot.log
When this log have more than ~1048000 b, this file is renamed to sript-bot.1.log

But now instead of creating new file, bot have problem with writing to new file and writes in command winddow:

(for claimit.py)

--- Logging error ---
Traceback (most recent call last):
  File "C:\Python38\lib\logging\handlers.py", line 70, in emit
    self.doRollover()
  File "I:\pwb\pywikibot\tools\_logging.py", line 57, in doRollover
    self.rotate(self.baseFilename, dfn)
  File "C:\Python38\lib\logging\handlers.py", line 111, in rotate
    os.rename(source, dest)
PermissionError: [WinError 32] Proces nemá přístup k souboru, neboť jej právě využívá jiný proces: 'i:\\pwb\\logs\\claimit-bot.log' -> 'i:\\pwb\\logs\\claimit-bot.1.log'
Call stack:
  File "I:\pwb\pwb.py", line 362, in <module>
    if __name__ == '__main__':
  File "I:\pwb\pwb.py", line 354, in main
    if check_modules(filename) or help_option:
  File "I:\pwb\pwb.py", line 73, in run_python_file
    source = f.read()
  File ".\scripts\claimit.py", line 161, in <module>
    main()
  File ".\scripts\claimit.py", line 157, in main
    bot.run()
  File "I:\pwb\pywikibot\bot.py", line 1590, in run
    """Update site before calling treat."""
  File "I:\pwb\pywikibot\bot.py", line 1501, in run
    self._generator_completed = True
  File "I:\pwb\pywikibot\bot.py", line 1780, in treat
    def put_current(self, new_text, ignore_save_related_errors=None,
  File "I:\pwb\pywikibot\bot.py", line 2235, in treat_page
    """
  File ".\scripts\claimit.py", line 94, in treat_page_and_item
    self.user_add_claim_unless_exists(
  File "I:\pwb\pywikibot\bot.py", line 2106, in user_add_claim_unless_exists
    if not existing.target_equals(claim.getTarget()):
  File "I:\pwb\pywikibot\logging.py", line 169, in log
    """Output a critical record to the user via the userinterface."""
  File "I:\pwb\pywikibot\logging.py", line 104, in logoutput
Message: 'Use -exists:p option to override this behavior'
Arguments: ()

Maybe this is caused by some restriction in windows 10 after last update (2004, 19041.572), but I updated pywikibot at the same time.

Event Timeline

It seems windows-specific, on Ubuntu 18.04 I get:

-rw-r--r-- 1 user user  973087 Oct 19 22:39  listpages-bot.2.log
-rw-r--r-- 1 user user  956838 Oct 19 22:39  listpages-bot.1.log
-rw-r--r-- 1 user user  840062 Oct 19 22:39  listpages-bot.log

I guess this is the same as in T93357. Are you running more than 1 script which writes to the
same log?