Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/sentry_sdk/__pycache__/_queue.cpython-311.pyc
�
��i� � � � d Z ddlZddlmZ ddlmZ ddlmZ erddlmZ g d�Z G d� d e
� � Z G d
� de
� � Z G d� d
e
� � ZdS )a�
A fork of Python 3.6's stdlib queue with Lock swapped out for RLock to avoid a
deadlock while garbage collecting.
See
https://codewithoutrules.com/2017/08/16/concurrency-python/
https://bugs.python.org/issue14976
https://github.com/sqlalchemy/sqlalchemy/blob/4eb747b61f0c1b1c25bdee3856d7195d10a0c227/lib/sqlalchemy/queue.py#L1
We also vendor the code to evade eventlet's broken monkeypatching, see
https://github.com/getsentry/sentry-python/pull/484
� N)�deque)�time)�MYPY)�Any)�Empty�Full�Queuec � � e Zd ZdZdS )r z4Exception raised by Queue.get(block=0)/get_nowait().N��__name__�
__module__�__qualname__�__doc__� � �H/opt/imunify360/venv/lib64/python3.11/site-packages/sentry_sdk/_queue.pyr r � � � � � � �:�:��Dr r c � � e Zd ZdZdS )r z4Exception raised by Queue.put(block=0)/put_nowait().Nr r r r r r r r r c �l � e Zd ZdZdd�Zd� Zd� Zd� Zd� Zd� Z dd�Z
dd�Zd
� Zd� Z
d� Zd� Zd� Zd� Zd
S )r zjCreate a queue object with a given maximum size.
If maxsize is <= 0, the queue size is infinite.
r c �0 � || _ | � |� � t j � � | _ t j | j � � | _ t j | j � � | _ t j | j � � | _ d| _ d S )Nr )
�maxsize�_init� threading�RLock�mutex� Condition� not_empty�not_full�all_tasks_done�unfinished_tasks��selfr s r �__init__zQueue.__init__+ s} � �����
�
�7���� �_�&�&��
� #�,�T�Z�8�8��� "�+�D�J�7�7��
� (�1�$�*�=�=��� !����r c �� � | j 5 | j dz
}|dk r.|dk rt d� � �| j � � � || _ ddd� � dS # 1 swxY w Y dS )a. Indicate that a formerly enqueued task is complete.
Used by Queue consumer threads. For each get() used to fetch a task,
a subsequent call to task_done() tells the queue that the processing
on the task is complete.
If a join() is currently blocking, it will resume when all items
have been processed (meaning that a task_done() call was received
for every item that had been put() into the queue).
Raises a ValueError if called more times than there were items
placed in the queue.
� r z!task_done() called too many timesN)r r �
ValueError�
notify_all)r"