#1034456 offlineimap: mail fails to sync when fcntl is used if portalocker is available

#1034456#5
Date:
2023-04-15 21:43:46 UTC
From:
To:
Greetings!

Thank you for maintaining offlineimap.

When I run offlineimap, several of my mailboxes fail to sync because are
attempting access symbols in the fcntl module in Python while the module is not
imported.

The problem comes from these lines 30-36 of offlineimap/imaplibutil.py in the
current verions of the Debian package in bookworm and sid:

The problem is because (a) I have portalocker installed on my system and (b)
the function "set_nonblocking" defined on line 140 of the same file relies on
fcntl being available.

I've not attached a patch because I'm not sure how to best to fix this.

I've fixed this on my system by simply importing fcntl in a line above the
quoted chunk of code above. The fcntl module is in the Python 3.11 standard
library in Python on Linux so it is should be safe. I believe fcntl might not
be installed on Windows.

It might be better to add new code to use portalocker instead of fcntl to the
function on line 140.

If it's helpful, I happy to help prepare a patch if you give me direction on
how you want to solve the problem.

Regards,
Mako