o
    ^"<f$  ã                   @   sN   d dl Z d dlZd dlZd dlmZ d dlmZ ere jZne jZdd„ Z	dS )é    N)ÚSynchronousOnlyOperation)ÚPY37c                    s(   ‡ fdd„}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  ˆ ¡‡ ‡fdd„ƒ}|S )Nc                     sL   t j d¡sztƒ }W n	 ty   Y nw ts| ¡ rtˆƒ‚ˆ | i |¤ŽS )NÚDJANGO_ALLOW_ASYNC_UNSAFE)ÚosÚenvironÚgetÚget_running_loopÚRuntimeErrorr   Ú
is_runningr   )ÚargsÚkwargsÚ
event_loop)ÚfuncÚmessage© úK/var/www/html/kck/venv/lib/python3.10/site-packages/django/utils/asyncio.pyÚinner   s   
ÿz.async_unsafe.<locals>.decorator.<locals>.inner)Ú	functoolsÚwraps)r   r   ©r   )r   r   Ú	decorator   s   zasync_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   )
Úasyncior   r   Údjango.core.exceptionsr   Údjango.utils.versionr   r   Úget_event_loopr   r   r   r   r   Ú<module>   s    