|
Server : LiteSpeed System : Linux barito.iixcp.rumahweb.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64 User : elvh3918 ( 1528) PHP Version : 8.2.31 Disable Function : mail Directory : /usr/local/lib/python3.9/site-packages/prompt_toolkit/eventloop/__pycache__/ |
a
��Sh� � @ s� d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl m
Z
mZmZm
Z
mZ g d�Ze
d�Zdd�d d
ddd
�dd�Zdddddd�dd�Zddd�dd�ZdS )� )�annotationsN)�get_running_loop)�
TracebackType)�Any� Awaitable�Callable�TypeVar�cast)�run_in_executor_with_context�call_soon_threadsafe�get_traceback_from_context�_T)�loopzCallable[..., _T]r z asyncio.AbstractEventLoop | Nonez
Awaitable[_T])�func�argsr �returnc G s* |pt � }t�� }|jd|j| g|�R � S )z�
Run a function in an executor, but make sure it uses the same contextvars.
This is required so that the function will see the right application.
See also: https://bugs.python.org/issue34014
N)r �contextvars�copy_context�run_in_executor�run)r r r �ctx� r �H/usr/local/lib/python3.9/site-packages/prompt_toolkit/eventloop/utils.pyr
s
r
zCallable[[], None]zfloat | None�None)r �max_postpone_timer r c sR |pt � �|du r ��� � dS t�� | �dd�� ���fdd������ dS )a�
Wrapper around asyncio's `call_soon_threadsafe`.
This takes a `max_postpone_time` which can be used to tune the urgency of
the method.
Asyncio runs tasks in first-in-first-out. However, this is not what we
want for the render function of the prompt_toolkit UI. Rendering is
expensive, but since the UI is invalidated very often, in some situations
we render the UI too often, so much that the rendering CPU usage slows down
the rest of the processing of the application. (Pymux is an example where
we have to balance the CPU time spend on rendering the UI, and parsing
process output.)
However, we want to set a deadline value, for when the rendering should
happen. (The UI should stay responsive).
Nr )r c s: t �dg �s� � d S t�� �kr,� � d S ���� d S )N�_ready)�getattr�timer r �r Zloop2Zmax_postpone_until�scheduler r r C s z&call_soon_threadsafe.<locals>.schedule)r r r )r r r r r r r % s
r zdict[str, Any]zTracebackType | None)�contextr c C s4 | � d�}|r0t|d�r$tt|j�S t�� d S dS )z4
Get the traceback object from the context.
� exception�
__traceback__� N)�get�hasattrr r r"