
     hf                         d dl Z d dlmZ d dlmZ d dlmZ d Z	 d dlm	Z	 dS # e
$ r d dlmZ  G d d	e          Z	Y dS w xY w)
    N)get_running_loopwraps)SynchronousOnlyOperationc                 N      f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                 @     t                      fd            }|S )Nc                      	 t                       t          j                            d          st	                    n# t
          $ r Y nw xY w | i |S )NDJANGO_ALLOW_ASYNC_UNSAFE)r   osenvirongetr   RuntimeError)argskwargsfuncmessages     S/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/django/utils/asyncio.pyinnerz.async_unsafe.<locals>.decorator.<locals>.inner   sy    < """ z~~&ABB <27;;;<      4((((s   A   
AAr   )r   r   r   s   ` r   	decoratorzasync_unsafe.<locals>.decorator   s9    	t
	) 
	) 
	) 
	) 
	) 

	)     zKYou cannot call this from an async context - use a thread or sync_to_async.)callable)r   r   r   s   `  r   async_unsafer      sS        "   	 yr   )aclosing)AbstractAsyncContextManagerc                   $    e Zd ZdZd Zd Zd ZdS )r   z
        Async context manager for safely finalizing an asynchronously
        cleaned-up resource such as an async generator, calling its
        ``aclose()`` method.
        c                     || _         d S Nthing)selfr   s     r   __init__zaclosing.__init__9   s    DJJJr   c                    K   | j         S r   r   )r    s    r   
__aenter__zaclosing.__aenter__<   s      :r   c                 H   K   | j                                          d {V  d S r   )r   aclose)r    exc_infos     r   	__aexit__zaclosing.__aexit__?   s2      *##%%%%%%%%%%%r   N)__name__
__module____qualname____doc__r!   r#   r'    r   r   r   r   2   sK        	 		 	 		 	 		& 	& 	& 	& 	&r   r   )r   asyncior   	functoolsr   django.core.exceptionsr   r   
contextlibr   ImportErrorr   r,   r   r   <module>r2      s    				 $ $ $ $ $ $       ; ; ; ; ; ;  D&######## & & &666666& & & & &. & & & & & &&s   # A A 