← Back
Editing: locks.cpython-311.pyc
� �|�e� � �0 � d Z ddlZdZd� Zej dk r�ddlZddlmZmZm Z m Z mZmZm Z mZmZ ddlmZmZmZ dZdZd Z ee� � ee � � k reZneZe Z G d � de� � Z G d� d e � � Z G d� de� � Z ee� � Zej j Zee_ eeeeeege_ ej j! Z!ee!_ eeeeege!_ d� Z"d� Z#dS ddl$Z$e$j Ze$j Ze$j Zd� Z"d� Z#dS # e%e&f$ r dxZxZZd� Z"d� Z#Y dS w xY w)aw Portable file locking utilities. Based partially on an example by Jonathan Feignberg in the Python Cookbook [1] (licensed under the Python Software License) and a ctypes port by Anatoly Techtonik for Roundup [2] (license [3]). [1] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203 [2] https://sourceforge.net/p/roundup/code/ci/default/tree/roundup/backends/portalocker.py [3] https://sourceforge.net/p/roundup/code/ci/default/tree/COPYING.txt Example Usage:: >>> from django.core.files import locks >>> with open('./file', 'wb') as f: ... locks.lock(f, locks.LOCK_EX) ... f.write('Django') � N)�LOCK_EX�LOCK_SH�LOCK_NB�lock�unlockc �N � t | d� � r| � � � n| S )zCGet a filedescriptor from something which could be a file or an fd.�fileno)�hasattrr ��fs �9/usr/lib/python3/dist-packages/django/core/files/locks.py�_fdr s# � � ��H�-�-�4�1�8�8�:�:�:�1�4� �nt) �POINTER� Structure�Union�byref�c_int64�c_ulong�c_void_p�sizeof�windll)�BOOL�DWORD�HANDLE� � c � � e Zd ZdefdefgZdS )�_OFFSET�Offset� OffsetHighN)�__name__� __module__�__qualname__r �_fields_� r r r r 2 s% � � � � � � �u�� �5�!�#���r r c �$ � e Zd ZdgZdefdefgZdS )� _OFFSET_UNION�_offset�PointerN)r# r$ r% �_anonymous_r �PVOIDr&