#1058077 portalocker: lock on NFS mount not working

Package:
src:portalocker
Source:
src:portalocker
Submitter:
Salvatore Bonaccorso
Date:
2025-05-02 21:18:02 UTC
Severity:
normal
Tags:
#1058077#5
Date:
2023-12-12 05:51:30 UTC
From:
To:
Hi

Locking on NFS mount does not work with portalocker, as a simple
reproducer:

,---- [ test-lock.py ]
| import portalocker
|
| file = open('/mnt/test.lock', mode='a')
|
| portalocker.lock(file, flags=portalocker.LOCK_SH|portalocker.LOCK_NB)
`----

which result in

	Traceback (most recent call last):
	  File "/usr/lib/python3/dist-packages/portalocker/portalocker.py", line 138, in lock
	    fcntl.flock(file_.fileno(), flags)
	OSError: [Errno 9] Bad file descriptor

	During handling of the above exception, another exception occurred:

	Traceback (most recent call last):
	  File "/mnt/./test-lock.py", line 5, in <module>
	    portalocker.lock(file, flags=portalocker.LOCK_SH|portalocker.LOCK_NB)
	  File "/usr/lib/python3/dist-packages/portalocker/portalocker.py", line 142, in lock
	    raise exceptions.LockException(exc_value, fh=file_)
	portalocker.exceptions.LockException: [Errno 9] Bad file descriptor

There is nothing specific which can be done in Debian at this point in
time, just filling the report referencing to the respective upstream
issue, so it can be fixed downstream as well.

Regards,
Salvatore

#1058077#12
Date:
2025-05-02 21:14:26 UTC
From:
To:
I've uploaded portalocker 3.1.1, which includes a patch that "fixes"
this issue, where basically upstream just handles the error properly with
a new exception.
Quoting upstream [0]:


However, I'm going to let this bug open since the package still has problems
supporting lock on NFS

[0]: https://github.com/wolph/portalocker/issues/92#issuecomment-2179532676