File: //usr/lib/python3/dist-packages/django/utils/__pycache__/asyncio.cpython-310.pyc
o
3�a$ � @ sN d dl Z d dlZd dlZd dlmZ d dlmZ ere jZne jZdd� Z dS )� N)�SynchronousOnlyOperation)�PY37c 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 sL t j�d�szt� }W n ty Y nw ts|�� rt���� | i |��S )N�DJANGO_ALLOW_ASYNC_UNSAFE)�os�environ�get�get_running_loop�RuntimeErrorr �
is_runningr )�args�kwargs�
event_loop)�func�message� �6/usr/lib/python3/dist-packages/django/utils/asyncio.py�inner s
�z.async_unsafe.<locals>.decorator.<locals>.inner)� functools�wraps)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 )
�asyncior r �django.core.exceptionsr �django.utils.versionr r �get_event_loopr r r r r �<module> s