harlowja / fasteners

A python package that provides useful locks.
Apache License 2.0
243 stars 45 forks source link

Executing release on InterProcessLock from cygwin yields: The argument must be an int or have a fileno method. #72

Closed nodiex-cloud closed 2 years ago

nodiex-cloud commented 3 years ago

Hello, I (with duplicity the backup soft) am using fastener from cygwin and creating a lock with InterProcessLock. When releasing the lock I am receiving the above error.

  1. What is the intended behavior of fastener on cygwin?
  2. Is cygwin suppose to behave like a POSIX filesystem or is the expected interaction with the file system for C/Python programs running in cygwin through the Win APIs?
psarka commented 3 years ago

Interesting, could you, please, paste the full stacktrace?

nodiex-cloud commented 3 years ago

Sure, this is what I am getting:

('Could not unlock the acquired lock opened on `%s`', b'/cg/j/restore_dest_5/data/elv_main/lockfile')
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/fasteners/process_lock.py", line 166, in release
    self.unlock()
  File "/usr/local/lib/python3.8/site-packages/fasteners/process_lock.py", line 193, in unlock
    self._unlock(self.lockfile)
  File "/usr/local/lib/python3.8/site-packages/fasteners/process_lock.py", line 430, in _unlock
    fcntl.lockf(lockfile, fcntl.LOCK_UN)
TypeError: argument must be an int, or have a fileno() method.
shoop commented 3 years ago

I see the same trace from duplicity 0.8.19 built with fasteners 0.16.1, at the end of every run. This is on a Linux host, duplicity run from within a container based on docker.io/library/python:3.9.5-slim. The volume /archive is mounted from a ZFS filesystem in the container.

('Could not unlock the acquired lock opened on `%s`', b'/archive/firsa_home_b2/lockfile')
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/fasteners/process_lock.py", line 166, in release
    self.unlock()
  File "/usr/local/lib/python3.9/site-packages/fasteners/process_lock.py", line 193, in unlock
    self._unlock(self.lockfile)
  File "/usr/local/lib/python3.9/site-packages/fasteners/process_lock.py", line 430, in _unlock
    fcntl.lockf(lockfile, fcntl.LOCK_UN)                                       
TypeError: argument must be an int, or have a fileno() method.                
psarka commented 3 years ago

@nodiex-cloud @shoop I cannot replicate this, could you please provide an example I could run and a bit more details about your environment?

I myself tried cygwin on windows 10 with python36 and python36-venv installed as cygwin packages. I then ran the tests for the process lock and they all pass.

Also, 0.16.1 was an errorneous release (my screw up, appologies for that!), could you please try with 0.16.2 or with master?

shoop commented 2 years ago

Hi @psarka , sorry for the delay in response. I can confirm that with fasteners 0.16.3 the problem has gone away for me.

psarka commented 2 years ago

Great, thanks!

psarka commented 2 years ago

Note: I found the root cause of this issue (see #82), and it has nothing to do with cygwin. Fasteners on cygwin run fine, and I would like them to continue to run fine.