Posts

Showing posts with the label cron

Cron i zc.lockfile

Musiałem dzisiaj napisać skrypt, który odpalał się co minutę poprzez crona i mogło się zdarzyć, że będzie wykonywał się trochę dłużej niż jedna minuta. Dlatego też, trzeba było wymyślić jakiś mechanizm, który by mnie uchronił przed odpaleniem skryptu kolejny raz, gdy ten jeszcze się nie wykonał. Z pomocą przyszedł mi moduł zc.lockfile . Instalujesz go normalnie poprzez pipa: pip install zc.lockfile Jak działa zc.lockfile? Krótki opis: The zc.lockfile package provides a basic portable implementation of interprocess locks using lock files. The purpose if not specifically to lock files, but to simply provide locks with an implementation based on file-locking primitives. Of course, these locks could be used to mediate access to  other  files. For example, the ZODB file storage implementation uses file locks to mediate access to file-storage database files. The database files and lock file files are separate files. Ja go użyłem w następujący sposób, w skrypcie zdefiniowałem odpo