
    h                     .    d dl Z d dlZd dlZd dlmZ d Zy)    N)SynchronousOnlyOperationc                 @      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                 F     t        j                          fd       }|S )Nc                      t         j                  j                  d      s0	 t        j                         }|j                         rt               | i |S # t        $ r Y w xY w)NDJANGO_ALLOW_ASYNC_UNSAFE)osenvirongetasyncioget_event_loop
is_runningr   RuntimeError)argskwargs
event_loopfuncmessages      W/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/django/utils/asyncio.pyinnerz.async_unsafe.<locals>.decorator.<locals>.inner   se    ::>>"=>@!(!7!7!9J ",,.6w??((( $ s   A 	A%$A%)	functoolswraps)r   r   r   s   ` r   	decoratorzasync_unsafe.<locals>.decorator   s%    			) 
	)     zKYou cannot call this from an async context - use a thread or sync_to_async.)callable)r   r   r   s   `  r   async_unsafer      s,    
  _r   )r   r   r   django.core.exceptionsr   r    r   r   <module>r      s      	 ;r   