
    Yf
                     8    d dl Z d dlZd dlmZmZ  G d d      Zy)    N)ListTuplec                   l    e Zd ZdZd
dZddeddfdZdeee	j                  f   fdZd Zdee   fd	Zy)ScaleneSignalszt
    ScaleneSignals class to configure timer signals for CPU profiling and
    to get various types of signals.
    returnNc                 h   | j                  d       t        j                  dk7  rjt        j                  | _        t        j                  | _        t        j                  | _	        t        j                  | _        t        j                  | _        y d | _        d | _        d | _	        d | _        d | _        y )NT)use_virtual_timewin32)set_timer_signalssysplatformsignalSIGILLstart_profiling_signalSIGBUSstop_profiling_signalSIGPROFmemcpy_signalSIGXCPUmalloc_signalSIGXFSZfree_signalselfs    W/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/scalene/scalene_signals.py__init__zScaleneSignals.__init__   s    5<<7"*0--D')/D&!'D!'D%~~D +/D')-D&!%D!%D#D    r	   c                    t         j                  dk(  rt        j                  | _        d| _        y|r+t        j                  | _        t        j                  | _        yt        j                  | _        t        j                  | _        y)z
        Set up timer signals for CPU profiling.

        use_virtual_time: bool, default True
            If True, sets virtual timer signals, otherwise sets real timer signals.
        r
   N)
r   r   r   SIGBREAK
cpu_signalcpu_timer_signalITIMER_VIRTUAL	SIGVTALRMITIMER_REALSIGALRM)r   r	   s     r   r   z ScaleneSignals.set_timer_signals    s]     <<7"$ooDO$(D!$*$9$9D!$..DO$*$6$6D!$nnDOr   c                 2    | j                   | j                  fS )z
        Return the signals used for CPU profiling.

        Returns:
        --------
        Tuple[int, signal.Signals]
            Returns 2-tuple of the integers representing the CPU timer signal and the CPU signal.
        )r!   r    r   s    r   get_timer_signalsz ScaleneSignals.get_timer_signals2   s     $$doo55r   c                 2    | j                   | j                  fS )N)r   r   r   s    r   get_lifecycle_signalsz$ScaleneSignals.get_lifecycle_signals<   s    ++T-G-GHHr   c                     | j                   | j                  | j                  | j                  | j                  | j
                  gS )z
        Return all the signals used for controlling profiling, except the CPU timer.

        Returns:
        --------
        List[int]
            Returns a list of integers representing all the profiling signals except the CPU timer.
        )r   r   r   r   r   r    r   s    r   get_all_signalszScaleneSignals.get_all_signals>   sB     ''&&OO
 	
r   )r   N)T)__name__
__module____qualname____doc__r   boolr   r   intr   Signalsr'   r)   r   r+    r   r   r   r      sO    
$&-$ -$ -$	65fnn)<#= 	6I
c 
r   r   )r   r   typingr   r   r   r3   r   r   <module>r5      s     
 G
 G
r   