Format: application/x-python-code
1 o
2
3 �h�i � @ s d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
4 mZ ddlm
5 Z
6 mZ ddlmZmZ ddlmZ ddlmZmZmZmZmZ ddlZddlmZ dd lmZ dd
7 lmZ dZdZ dZ!G d
8 d� d�Z"G dd� d�Z#G dd� de�Z$dS )z.Wrappers for forwarding stdout/stderr over zmq� N)�b2a_hex)�defaultdict�deque)�StringIO�
9 TextIOBase)�local)�Any�Callable�Deque�Dict�Optional)�extract_header)�IOLoop)� ZMQStream� i� c @ s� e Zd ZdZd*dd�Zdd� Zdd� Zd d
10 � Zdd� Ze d
11 d� �Z
12 dd� Zdd� Zdd� Z
13 dd� Zdd� Zdd� Zdd� Zdd� Zdd � Ze d!d"� �Zd#d$� Zd%d&� Zd'd(� Zd)S )+�IOPubThreada An object for sending IOPub messages in a background thread
14
15 Prevents a blocking main thread from delaying output from threads.
16
17 IOPubThread(pub_socket).background_socket is a Socket-API-providing object
18 whose IO is always run in a thread.
19 Fc C s� || _ d| _t| �| _t�� | _|| _tdd�| _ |r| �
20 � t�� | _
21 t� | _i | _t�� | _d| _d| _| �� tj| jdd�| _d| j_d| j_d| j_d| j_dS )a Create IOPub thread
22
23 Parameters
24 ----------
25 socket : zmq.PUB Socket
26 the socket on which messages will be sent.
27 pipe : bool
28 Whether this process should listen for IOPub messages
29 piped from subprocesses.
30 F)Zmake_current�
31 N�IOPub)�target�nameT)�socket�_stopped�BackgroundSocketZbackground_socket�os�getpid�_master_pid�
32 _pipe_flagr �io_loop�_setup_pipe_in� threadingr �_localr �_events�_event_pipes�Lock�_event_pipe_gc_lock�_event_pipe_gc_seconds�_event_pipe_gc_task�_setup_event_pipe�Thread�_thread_main�thread�daemonZpydev_do_not_traceZis_pydev_daemon_threadr )�selfr �pipe� r. �Hc:\Users\shubh\Videos\agent\nova\Lib\site-packages\ipykernel/iostream.py�__init__1 s(
33
34
35
36 zIOPubThread.__init__c sn � fdd�}� j �|� � js� j �� � jdur.� fdd�}� js)� j �|� n� j�� � j jdd� dS )z.The inner loop that's actually run in a threadc s t �� �� �� _d S �N)�asyncio�
37 ensure_future�_run_event_pipe_gcr&