관리-도구
편집 파일: sqlitelockfile.cpython-311.pyc
� N�Dg� � � � d dl mZmZ d dlZd dlZ e n # e$ r eZY nw xY wddlm Z m Z mZmZm Z G d� de � � ZdS )� )�absolute_import�divisionN� )�LockBase� NotLocked� NotMyLock�LockTimeout� AlreadyLockedc �D � e Zd ZdZdZdd�Zdd�Zd� Zd� Zd� Z d � Z d � ZdS ) �SQLiteLockFilezDemonstrate SQL-based locking.NTc � � t j | |||� � t | j � � | _ t | j � � | _ t j �Qddl}|� � � \ }}t j |� � t j |� � ~~|t _ ddl}|� t j � � | _ | j � � � } |� d� � | j � � � ddl} | � t j t j � � dS # |j $ r Y dS w xY w)zu >>> lock = SQLiteLockFile('somefile') >>> lock = SQLiteLockFile('somefile', threaded=False) Nr zGcreate table locks( lock_file varchar(32), unique_name varchar(32)))r �__init__�unicode� lock_file�unique_namer �testdb�tempfile�mkstemp�os�close�unlink�sqlite3�connect� connection�cursor�execute�commit�atexit�register�OperationalError) �self�path�threaded�timeoutr �_fdr r �cr s �w/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/lockfile/sqlitelockfile.pyr zSQLiteLockFile.__init__ sG � � ��$��h��8�8�8� ���0�0���"�4�#3�4�4���� �(��O�O�O�"�*�*�,�,�K�C���H�S�M�M�M��I�f�����X�$*�N�!�����!�/�/�.�*?�@�@����O�"�"�$�$�� >� �I�I� � � � � �O�"�"�$�$�$��M�M�M��O�O�B�I�~�'<�=�=�=�=�=�� �'� � � ��D�D� ���s �)E � E�Ec � � |�|n| j }t j � � }|�|dk r||z }|�d}n|dk rd}n|dz }| j � � � } | � � � s�|� d| j | j f� � | j � � � |� d| j f� � |� � � }t |� � dk r6|� d| j f� � | j � � � nGd S |� d| j f� � |� � � }t |� � dk rd S |�Kt j � � |k r4|dk rt d | j z � � �t d | j z � � �t j |� � ��r)Nr g�������?� Tz;insert into locks (lock_file, unique_name) values (?, ?)z*select * from locks where unique_name = ?r �(delete from locks where unique_name = ?z&Timeout waiting to acquire lock for %sz%s is already locked)r$ �timer r � is_lockedr r r r �fetchall�lenr r"