File: //usr/local/CyberCP/lib/python3.10/site-packages/django/utils/__pycache__/asyncio.cpython-310.pyc
o
�hf � @ sx d dl Z d dlmZ d dlmZ d dlmZ dd� Zz d dlm Z W dS e
y; d dlmZ G d d
� d
e�Z Y dS w )� N)�get_running_loop��wraps)�SynchronousOnlyOperationc s( � fdd�}t � �r� }d� ||�S |S )z�
Decorator to mark functions as async-unsafe. Someone trying to access
the function while in an async context will get an error message.
c s t � �� �fdd��}|S )Nc s@ zt � W n ty Y nw tj�d�st���� | i |��S )N�DJANGO_ALLOW_ASYNC_UNSAFE)r �RuntimeError�os�environ�getr )�args�kwargs)�func�message� �G/usr/local/CyberCP/lib/python3.10/site-packages/django/utils/asyncio.py�inner s
�z.async_unsafe.<locals>.decorator.<locals>.innerr )r
r �r )r
r � decorator s zasync_unsafe.<locals>.decoratorzKYou cannot call this from an async context - use a thread or sync_to_async.)�callable)r r r
r r r �async_unsafe s �r )�aclosing)�AbstractAsyncContextManagerc @ s( e Zd ZdZdd� Zdd� Zdd� ZdS ) r z�
Async context manager for safely finalizing an asynchronously
cleaned-up resource such as an async generator, calling its
``aclose()`` method.
c C s
|| _ d S �N��thing)�selfr r r r �__init__9 s
zaclosing.__init__c � s �| j S r r )r r r r �
__aenter__<