o
    
hr                     @   s8   d dl Z d dlmZ d dlmZ d dlmZ dd ZdS )    N)get_running_loopwraps)SynchronousOnlyOperationc                    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                     s@   zt   W n	 ty   Y nw tjdst | i |S )NDJANGO_ALLOW_ASYNC_UNSAFE)r   RuntimeErrorosenvirongetr   )argskwargs)funcmessage V/var/www/html/optinet_system/venv/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   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   )r   asyncior   	functoolsr   django.core.exceptionsr   r   r   r   r   r   <module>   s
    