# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
+import logging
import os
import sys
import tempfile
import zc.lockfile
+logging.basicConfig(level=logging.INFO)
+logger = logging.getLogger(__name__)
+
# Lock file
lockfile = tempfile.gettempdir() + '/fba.lock'
LOCK = None
def acquire():
global LOCK
- # DEBUG: print("DEBUG: CALLED!")
+ logger.debug("CALLED!")
try:
- # DEBUG: print(f"DEBUG: Acquiring lock: '{lockfile}'")
+ logger.debug("Acquiring lock: lockfile='%s'", lockfile)
LOCK = zc.lockfile.LockFile(lockfile)
- # DEBUG: print("DEBUG: Lock obtained.")
+ logger.debug("Lock obtained.")
except zc.lockfile.LockError:
- print(f"ERROR: Cannot aquire lock: '{lockfile}'")
+ logger.error("Cannot aquire lock: lockfile='%s'", lockfile)
sys.exit(100)
- # DEBUG: print("DEBUG: EXIT!")
+ logger.debug("EXIT!")
def release():
- # DEBUG: print("DEBUG: CALLED!")
+ logger.debug("CALLED!")
if LOCK is not None:
- # DEBUG: print("DEBUG: Releasing lock ...")
+ logger.debug("Releasing lock ...")
LOCK.close()
- # DEBUG: print(f"DEBUG: Deleting lockfile='{lockfile}' ...")
+
+ logger.debug("Deleting lockfile='%s' ...", lockfile)
os.remove(lockfile)
- # DEBUG: print("DEBUG: EXIT!")
+ logger.debug("EXIT!")