OwlCyberSecurity - MANAGER
Edit File: asyncio.cpython-39.pyc
a ���ef � @ sx d dl Z d dlmZ d dlmZ d dlmZ dd� Zzd dlm Z W n. e yr d dlmZ G d d � d e�Z Y n0 dS )� N)�get_running_loop��wraps)�SynchronousOnlyOperationc s, � fdd�}t � �r$� }d� ||�S |S dS )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 s@ z t � W n ty Y n0 tj�d�s2t���� | i |��S )NZDJANGO_ALLOW_ASYNC_UNSAFE)r �RuntimeError�os�environ�getr )�args�kwargs)�func�message� �U/home/gouroczh/virtualenv/pat/3.9/lib/python3.9/site-packages/django/utils/asyncio.py�inner s z.async_unsafe.<locals>.decorator.<locals>.innerr )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.N)�callable)r r r r r r �async_unsafe s �r )�aclosing)�AbstractAsyncContextManagerc @ s( e Zd ZdZdd� Zdd� Zdd� ZdS ) r z� Async context manager for safely finalizing an asynchronously cleaned-up resource such as an async generator, calling its ``aclose()`` method. c C s || _ d S �N��thing)�selfr r r r �__init__9 s zaclosing.__init__c � s | j S r r )r r r r � __aenter__<