| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/IPython/lib/__pycache__/ |
Upload File : |
�
�@�cJE � � � d Z ddlZddlZddlmZ ddlmZ ddlmZm Z G d� de
� � Z G d� d ej � � Z
G d
� de
� � Z G d� d
e
� � ZdS )a
Manage background (threaded) jobs conveniently from an interactive shell.
This module provides a BackgroundJobManager class. This is the main class
meant for public usage, it implements an object which can create and manage
new background jobs.
It also provides the actual job classes managed by these BackgroundJobManager
objects, see their docstrings below.
This system was inspired by discussions with B. Granger and the
BackgroundCommand class described in the book Python Scripting for
Computational Science, by H. P. Langtangen:
http://folk.uio.no/hpl/scripting
(although ultimately no code from this text was used, as IPython's system is a
separate implementation).
An example notebook is provided in our documentation illustrating interactive
use of the system.
� N)�get_ipython)�AutoFormattedTB)�error�debugc � � e Zd ZdZd� Zed� � � Zed� � � Zed� � � Zd� Z d� Z
d� Zd � Zd
� Z
d� Zd� Zdd�Zd� Zd� Zd� Zd� Zdd�ZdS )�BackgroundJobManagera� Class to manage a pool of backgrounded threaded jobs.
Below, we assume that 'jobs' is a BackgroundJobManager instance.
Usage summary (see the method docstrings for details):
jobs.new(...) -> start a new job
jobs() or jobs.status() -> print status summary of all jobs
jobs[N] -> returns job number N.
foo = jobs[N].result -> assign to variable foo the result of job N
jobs[N].traceback() -> print the traceback of dead job N
jobs.remove(N) -> remove (finished) job N
jobs.flush() -> remove all finished jobs
As a convenience feature, BackgroundJobManager instances provide the
utility result and traceback methods which retrieve the corresponding
information from the jobs list:
jobs.result(N) <--> jobs[N].result
jobs.traceback(N) <--> jobs[N].traceback()
While this appears minor, it allows you to use tab completion
interactively on the job manager instance.
c �� � g | _ g | _ g | _ i | _ g | _ g | _ t j | _ t j | _
t j | _ t j
| _ d| _ d S )Nr )�_running�
_completed�_dead�all�_comp_report�_dead_report�BackgroundJobBase�stat_created_c�
_s_created�stat_running_c�
_s_running�stat_completed_c�_s_completed�stat_dead_c�_s_dead�_current_job_id��selfs �</usr/lib/python3/dist-packages/IPython/lib/backgroundjobs.py�__init__zBackgroundJobManager.__init__I sg � � ��
������
����������-�<���-�<���-�>���-�9��� ����� c �8 � | � � � | j S �N)�_update_statusr
r s r �runningzBackgroundJobManager.running[ s � ��������}�r c �8 � | � � � | j S r )r! r r s r �deadzBackgroundJobManager.dead` s � ��������z�r c �8 � | � � � | j S r )r! r r s r � completedzBackgroundJobManager.completede s � ���������r c �� � t |� � r'|� di � � }t |g|�R i |��}n�t |t � � r}|s#t j d� � }|j |j }}nFt |� � dk r|d x}}n(t |� � dk r|\ }}nt d� � �t |||� � }nt d� � �|� dd� � rd |_
| j |_ | xj dz
c_ | j � |� � || j |j <