BlacklistUpdater fails to create blacklist.txt on new install #6
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: karolyi/py3-validate-email#6
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
On a fresh install, where blacklist.txt is not yet present,
BlacklistUpdater.process()
fails because it tries to lock that non-existent file.I see that setup.py should run
BlacklistUpdater.process()
, but it doesn't, at least not when installing withpip install
. And if it would, it would obviously fail for the same reason anyway.On a side note, I think that putting the updateable file inside the validate_email directory might lead to problems because on a system install, that directory might not be writeable for the process that actually runs the code.
Hey,
thanks for reporting this issue. I will be testing this out soon along with the read-only filesystem problem and provide an update.
Probably I'll include a change where the blacklist.txt will get put into a
/tmp
like filesystem part (anything python suggests withtempfile
).I just did some further debugging and found out that the file lock does not fail because of the non-existent file, but rather because, in my test environment, the file would have been within an NFS mounted directory tree. If I move everything to a directory tree on the local hard disk, it works as expected.
I still think that putting it on
/tmp
is a good idea.Are you saying that you can't create and then lock a file on NFS?
I think I'll change the lock to lock the updater.py itself, so it's an already existing file. The question is, can you lock an existing file via your NFS? I think both the creation and lock should work.
It's important to lock because it's the only way of avoiding multiple updates when more than one processes are fired up in the same time (e.g. UWSGI starts instances of code that use this module).
I found the root of the problem: see https://manpages.debian.org/buster/manpages-dev/flock.2.en.html section "NFS details":
And indeed, if I change
into
it works perfectly.
Still it might be more portable to different situations and operating systems if you use, for example, https://pypi.org/project/filelock/.