Windows - PermissionError: [Errno 13] Permission denied
Maxiviper117 opened this issue · comments
Hi
When testing out this example in windows:
from logging import getLogger, INFO
from concurrent_log_handler import ConcurrentRotatingFileHandler
import os
log = getLogger(__name__)
# Use an absolute path to prevent file rotation trouble.
logfile = os.path.abspath("mylogfile.log")
# Rotate log after reaching 512K, keep 5 old copies.
rotateHandler = ConcurrentRotatingFileHandler(logfile, "a", 512*1024, 5)
log.addHandler(rotateHandler)
log.setLevel(INFO)
log.info("Here is a very exciting log message, just for you")
It produces this Permission error.
--- Logging error ---
Traceback (most recent call last):
File "/Users/davig/opt/anaconda3/lib/python3.9/site-packages/concurrent_log_handler/__init__.py", line 327, in emit
self._do_lock()
File "/Users/davig/opt/anaconda3/lib/python3.9/site-packages/concurrent_log_handler/__init__.py", line 404, in _do_lock
self._open_lockfile()
File "/Users/davig/opt/anaconda3/lib/python3.9/site-packages/concurrent_log_handler/__init__.py", line 249, in _open_lockfile
self.stream_lock = open(lock_file, "wb", buffering=0)
PermissionError: [Errno 13] Permission denied: '/Volumes/GoogleDrive/My Drive/[All Python Projects]/PYTHON PRACTICE/.__mylogfile.lock'
Call stack:
File "/Volumes/GoogleDrive/My Drive/[All Python Projects]/PYTHON PRACTICE/LOGGING_/concurrent_log_handler/test.py", line 13, in <module>
log.info("Here is a very exciting log message, just for you")
File "/Users/davig/opt/anaconda3/lib/python3.9/logging/__init__.py", line 1446, in info
self._log(INFO, msg, args, **kwargs)
File "/Users/davig/opt/anaconda3/lib/python3.9/logging/__init__.py", line 1589, in _log
self.handle(record)
File "/Users/davig/opt/anaconda3/lib/python3.9/logging/__init__.py", line 1599, in handle
self.callHandlers(record)
File "/Users/davig/opt/anaconda3/lib/python3.9/logging/__init__.py", line 1661, in callHandlers
hdlr.handle(record)
File "/Users/davig/opt/anaconda3/lib/python3.9/logging/__init__.py", line 952, in handle
self.emit(record)
File "/Users/davig/opt/anaconda3/lib/python3.9/site-packages/concurrent_log_handler/__init__.py", line 343, in emit
self.handleError(record)
Message: 'Here is a very exciting log message, just for you'
Arguments: ()
(base) davig@Davids-MacBook-Air PYTHON PRACTICE %
How would I resolve this for running it on windows?
Ahh, just realised now, problem is I'm running the code from synced desktop google drive file.
Yeah, that could do it. The problem is portalocker and the lock file. Using a location on a synced folder like Google Drive, Dropbox, OneDrive, etc, might cause issues.
There is a PR outstanding #50 that will provide a way to specify an alternate lock file location, which could address your issue. I'm planning to tackle that PR after #48 is finished up.