Closed 1480c1 closed 2 years ago
I'll need to get access to a windows machine to debug this
I ran into this today:
I changed the code for locking in windows to be like this:
if os.name == 'nt':
import msvcrt
def lock(self):
msvcrt.locking(self.fp.fileno(), msvcrt.LK_LOCK, 1)
self.locked = True
def unlock(self):
if self.locked:
msvcrt.locking(self.fp.fileno(), msvcrt.LK_UNLCK, 1)
self.locked = False
However, with this I still get an error unlocking the file:
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File ".\crudini\crudini.py", line 193, in delete
self.unlock()
File ".\crudini\crudini.py", line 101, in unlock
msvcrt.locking(self.fp.fileno(), msvcrt.LK_UNLCK, 32)
PermissionError: [Errno 13] Permission denied
Switching lib to portalocker
seems to work ... will put out a PR once ive done some more testing:
import portalocker
def lock(self):
portalocker.lock(self.fp, portalocker.LOCK_EX)
self.locked = True
def unlock(self):
if self.locked:
portalocker.unlock(self.fp)
self.locked = False
Ahhh even though that works not been able to get set
to work on Windows:
[WinError 5] Access is denied: 'C:\\Dev\\crudini\\example.ini.3ureg9f8.tmp' -> 'C:\\Dev\\crudini\\example.ini'
This is even running as admin happens on this line https://github.com/pixelb/crudini/blob/master/crudini#L375
Unfortunatley think thats where my python knowedge dries up. Gonna have to attempt another solution to dealing with ini files :(
Addressed in commit 0f2c0b03
Windows 10 python installed through
choco install python2
python ./crudini --help
and version work fine