HEX
Server: LiteSpeed
System: Linux atali.colombiahosting.com.co 5.14.0-570.12.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 13 06:11:55 EDT 2025 x86_64
User: coopserp (1713)
PHP: 8.2.29
Disabled: dl,exec,passthru,proc_open,proc_close,shell_exec,memory_limit,system,popen,curl_multi_exec,show_source,symlink,link,leak,listen,diskfreespace,tmpfile,ignore_user_abord,highlight_file,source,show_source,fpaththru,virtual,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setid,posix_times,posix_ttyname,posix_uname,proc_get_status,proc_nice,proc_terminate
Upload Files
File: //usr/local/lib64/python3.9/site-packages/psutil/tests/__pycache__/test_memleaks.cpython-39.pyc
a

��?h3<�@sdZddlmZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZdd	lm
Z
dd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%dd lm&Z&dd!lm'Z'ej(j)Z)e�*�Z+d"Z,d#d$�Z-Gd%d&�d&e�Z.Gd'd(�d(e.�Z/e#j0j1e
d)d*�Gd+d,�d,e��Z2Gd-d.�d.e�Z3dS)/a�Tests for detecting function memory leaks (typically the ones
implemented in C). It does so by calling a function many times and
checking whether process memory usage keeps increasing between
calls or over time.
Note that this may produce false positives (especially on Windows
for some reason).
PyPy appears to be completely unstable for this framework, probably
because of how its JIT handles memory, so tests are skipped.
�)�print_functionN)�LINUX)�MACOS)�OPENBSD)�POSIX)�SUNOS)�WINDOWS)�ProcessLookupError)�super)�HAS_CPU_AFFINITY)�HAS_CPU_FREQ)�HAS_ENVIRON)�
HAS_IONICE)�HAS_MEMORY_MAPS)�HAS_NET_IO_COUNTERS)�HAS_PROC_CPU_NUM)�HAS_PROC_IO_COUNTERS)�
HAS_RLIMIT)�HAS_SENSORS_BATTERY)�HAS_SENSORS_FANS)�HAS_SENSORS_TEMPERATURES)�	QEMU_USER)�TestMemoryLeak)�create_sockets)�
get_testfn)�process_namespace)�pytest)�skip_on_access_denied)�spawn_testproc)�system_namespace)�	terminate�cCsdd�}|S)zsDecorator for those Linux functions which are implemented in pure
    Python, and which we want to run faster.
    cst����fdd��}|S)Ncs\trB|jj}z(t|j_�|g|�Ri|��W||j_S||j_0n�|g|�Ri|��SdS�N)r�	__class__�times�	FEW_TIMES)�self�args�kwargs�before��fun��F/usr/local/lib64/python3.9/site-packages/psutil/tests/test_memleaks.py�wrapperDs�z5fewtimes_if_linux.<locals>.decorator.<locals>.wrapper)�	functools�wraps)r+r.r,r*r-�	decoratorCsz$fewtimes_if_linux.<locals>.decoratorr,)r1r,r,r-�fewtimes_if_linux>sr2c@s0eZdZdZeZdd�Ze�dd��Ze�dd��Z	e�dd	��Z
e�d
d��Zej
jedd
�e�dd���Zej
jedd
�e�dd���Ze�dd��Zdd�Zdd�Zej
jedd
�dd��Zej
jedd
�dd��Zej
jedd
�e�dd���Zej
jedd
�d d!��Ze�d"d#��Ze�eed$�d%d&���Zej
jed'd
�d(d)��Z ej
jedd
�e�d*d+���Z!e�d,d-��Z"e�eed$�d.d/���Z#e�d0d1��Z$e�ej
je%dd
�d2d3���Z&e�d4d5��Z'e�d6d7��Z(ej
jedd
�e�d8d9���Z)d:d;�Z*e�d<d=��Z+ej
je,dd
�d>d?��Z-ej
je,dd
�d@dA��Z.e�dBdC��Z/ej
je0dd
�e�dDdE���Z1ej
je2dFd
�ej
je3dd
�dGdH���Z4ej
je2dFd
�ej
je3dd
�dIdJ���Z5e�ej
jedKd
�dLdM���Z6ej
je7dd
�dNdO��Z8ej
jed'd
�dPdQ��Z9dRS)S�TestProcessObjectLeaksz$Test leaks of Process class methods.cCs td�}|�||j|j�dSr")r�test_class_coverageZgettersZsetters�r&�nsr,r,r-�
test_coverage_sz$TestProcessObjectLeaks.test_coveragecCs|�|jj�dSr")�execute�proc�name�r&r,r,r-�	test_namecsz TestProcessObjectLeaks.test_namecCs|�|jj�dSr")r8r9Zcmdliner;r,r,r-�test_cmdlinegsz#TestProcessObjectLeaks.test_cmdlinecCs|�|jj�dSr")r8r9Zexer;r,r,r-�test_exekszTestProcessObjectLeaks.test_execCs|�|jj�dSr")r8r9Zppidr;r,r,r-�	test_ppidosz TestProcessObjectLeaks.test_ppidz
POSIX only��reasoncCs|�|jj�dSr")r8r9Zuidsr;r,r,r-�	test_uidsssz TestProcessObjectLeaks.test_uidscCs|�|jj�dSr")r8r9�gidsr;r,r,r-�	test_gidsxsz TestProcessObjectLeaks.test_gidscCs|�|jj�dSr")r8r9�statusr;r,r,r-�test_status}sz"TestProcessObjectLeaks.test_statuscCs|�|jj�dSr")r8r9�nicer;r,r,r-�	test_nice�sz TestProcessObjectLeaks.test_nicecs t�������fdd��dS)Ncs�j���Sr")r9rGr,�Znicenessr&r,r-�<lambda>��z6TestProcessObjectLeaks.test_nice_set.<locals>.<lambda>)�thisprocrGr8r;r,rIr-�
test_nice_set�sz$TestProcessObjectLeaks.test_nice_set�
not supportedcCs|�|jj�dSr")r8r9�ionicer;r,r,r-�test_ionice�sz"TestProcessObjectLeaks.test_ionicecsZtr"t�������fdd��n4���fdd��t�tjt�	�dd�}��
t|�dS)Ncs�j���Sr")r9rOr,�r&�valuer,r-rJ�rKz8TestProcessObjectLeaks.test_ionice_set.<locals>.<lambda>cs�j�tj�Sr")r9rO�psutilZIOPRIO_CLASS_NONEr,r;r,r-rJ�rK���r)rrLrOr8r/�partial�cextZproc_ioprio_set�os�getpid�
execute_w_exc�OSError�r&r+r,rQr-�test_ionice_set�sz&TestProcessObjectLeaks.test_ionice_setcCs|�|jj�dSr")r8r9Zio_countersr;r,r,r-�test_io_counters�sz'TestProcessObjectLeaks.test_io_counterszworthless on POSIXcCst����|�|jj�dSr")rS�Process�usernamer8r9r;r,r,r-�
test_username�sz$TestProcessObjectLeaks.test_usernamecCs|�|jj�dSr")r8r9Zcreate_timer;r,r,r-�test_create_time�sz'TestProcessObjectLeaks.test_create_time)Zonly_ifcCs|�|jj�dSr")r8r9Znum_threadsr;r,r,r-�test_num_threads�sz'TestProcessObjectLeaks.test_num_threads�WINDOWS onlycCs|�|jj�dSr")r8r9Znum_handlesr;r,r,r-�test_num_handles�sz'TestProcessObjectLeaks.test_num_handlescCs|�|jj�dSr")r8r9Znum_fdsr;r,r,r-�test_num_fds�sz#TestProcessObjectLeaks.test_num_fdscCs|�|jj�dSr")r8r9Znum_ctx_switchesr;r,r,r-�test_num_ctx_switches�sz,TestProcessObjectLeaks.test_num_ctx_switchescCs|�|jj�dSr")r8r9�threadsr;r,r,r-�test_threads�sz#TestProcessObjectLeaks.test_threadscCs|�|jj�dSr")r8r9�	cpu_timesr;r,r,r-�test_cpu_times�sz%TestProcessObjectLeaks.test_cpu_timescCs|�|jj�dSr")r8r9Zcpu_numr;r,r,r-�test_cpu_num�sz#TestProcessObjectLeaks.test_cpu_numcCs|�|jj�dSr")r8r9Zmemory_infor;r,r,r-�test_memory_info�sz'TestProcessObjectLeaks.test_memory_infocCs|�|jj�dSr")r8r9Zmemory_full_infor;r,r,r-�test_memory_full_info�sz,TestProcessObjectLeaks.test_memory_full_infocCs|�|jj�dSr")r8r9Zterminalr;r,r,r-�
test_terminal�sz$TestProcessObjectLeaks.test_terminalcCs$trtn|j}|j|jj|d�dS)N�r$)rr%r$r8r9�resume�r&r$r,r,r-�test_resume�sz"TestProcessObjectLeaks.test_resumecCs|�|jj�dSr")r8r9�cwdr;r,r,r-�test_cwd�szTestProcessObjectLeaks.test_cwdcCs|�|jj�dSr")r8r9�cpu_affinityr;r,r,r-�test_cpu_affinity�sz(TestProcessObjectLeaks.test_cpu_affinitycs4t�������fdd����t�fdd��dS)Ncs�j���Sr"�r9rur,�Zaffinityr&r,r-rJ�rKz>TestProcessObjectLeaks.test_cpu_affinity_set.<locals>.<lambda>cs�j�dg�S�NrTrwr,r;r,r-rJ�rK)rLrur8rY�
ValueErrorr;r,rxr-�test_cpu_affinity_set�sz,TestProcessObjectLeaks.test_cpu_affinity_setcCs>tt�d��|�|jj�Wd�n1s00YdS)N�w)�openrr8r9Z
open_filesr;r,r,r-�test_open_files�sz&TestProcessObjectLeaks.test_open_filescCs|�|jj�dSr")r8r9Zmemory_mapsr;r,r,r-�test_memory_maps�sz'TestProcessObjectLeaks.test_memory_mapsz
LINUX onlycs���fdd��dS)Ncs�j�tj�Sr"�r9�rlimitrS�
RLIMIT_NOFILEr,r;r,r-rJ�rKz4TestProcessObjectLeaks.test_rlimit.<locals>.<lambda>�r8r;r,r;r-�test_rlimit�sz"TestProcessObjectLeaks.test_rlimitcs<t�tj������fdd����ttf�fdd��dS)Ncs�j�tj��Sr"r�r,��limitr&r,r-rJ�rKz8TestProcessObjectLeaks.test_rlimit_set.<locals>.<lambda>cs�j�d�Sry)r9r�r,r;r,r-rJ�rK)rLr�rSr�r8rYrZrzr;r,r�r-�test_rlimit_set�sz&TestProcessObjectLeaks.test_rlimit_setzworthless on WINDOWScsJt��0trdnd�����fdd��Wd�n1s<0YdS)NZinet�allcs�j���Sr")r9�net_connectionsr,��kindr&r,r-rJrKz=TestProcessObjectLeaks.test_net_connections.<locals>.<lambda>)rrr8r;r,r�r-�test_net_connections�sz+TestProcessObjectLeaks.test_net_connectionscCs|�|jj�dSr")r8r9�environr;r,r,r-�test_environsz#TestProcessObjectLeaks.test_environcCs|�dd��dS)NcSst�t���Sr")rV�	proc_inforWrXr,r,r,r-rJrKz7TestProcessObjectLeaks.test_proc_info.<locals>.<lambda>r�r;r,r,r-�test_proc_info
sz%TestProcessObjectLeaks.test_proc_infoN):�__name__�
__module__�__qualname__�__doc__rLr9r7r2r<r=r>r?r�mark�skipifrrBrDrFrHrMrrPr\rr]r`rarrrbrrdrerfrhrjrrkrlrmrnrrrtrrvr{r~rrrrr�r�r�r
r�r�r,r,r,r-r3Zs�






	











r3cspeZdZdZe�fdd��Ze�fdd��Zdd�Zerhdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Z�ZS)�TestTerminatedProcessLeaksz�Repeat the tests above looking for leaks occurring when dealing
    with terminated processes raising NoSuchProcess exception.
    The C functions are still invoked but will follow different code
    paths. We'll check those code paths.
    cs:t���t�|_t�|jj�|_|j��|j�	�dSr")
r
�
setUpClassr�subprSr^�pidr9�kill�wait��cls�r#r,r-r�s


z%TestTerminatedProcessLeaks.setUpClasscst���t|j�dSr")r
�
tearDownClassr r�r�r�r,r-r�s
z(TestTerminatedProcessLeaks.tearDownClasscCs$z
|�WntjyYn0dSr")rSZ
NoSuchProcessr[r,r,r-�call#s
zTestTerminatedProcessLeaks.callcCs|�|jj�dSr")r8r9r�r;r,r,r-�	test_kill+sz$TestTerminatedProcessLeaks.test_killcCs|�|jj�dSr")r8r9r r;r,r,r-�test_terminate.sz)TestTerminatedProcessLeaks.test_terminatecCs|�|jj�dSr")r8r9Zsuspendr;r,r,r-�test_suspend1sz'TestTerminatedProcessLeaks.test_suspendcCs|�|jj�dSr")r8r9rpr;r,r,r-rr4sz&TestTerminatedProcessLeaks.test_resumecCs|�|jj�dSr")r8r9r�r;r,r,r-�	test_wait7sz$TestTerminatedProcessLeaks.test_waitcs�fdd�}��|�dS)Ncs(zt��jj�WSty"Yn0dSr")rVr�r9r�r	r,r;r,r-r�<sz7TestTerminatedProcessLeaks.test_proc_info.<locals>.callr�)r&r�r,r;r-r�:sz)TestTerminatedProcessLeaks.test_proc_info)r�r�r�r��classmethodr�r�r�rr�r�r�rrr�r��
__classcell__r,r,r�r-r�sr�rcr@c@seZdZdd�Zdd�ZdS)�TestProcessDualImplementationcCs|�dd��dS)NcSstjt��dd�S)NT�Zuse_peb�rVZproc_cmdlinerWrXr,r,r,r-rJHrKzETestProcessDualImplementation.test_cmdline_peb_true.<locals>.<lambda>r�r;r,r,r-�test_cmdline_peb_trueGsz3TestProcessDualImplementation.test_cmdline_peb_truecCs|�dd��dS)NcSstjt��dd�S)NFr�r�r,r,r,r-rJKrKzFTestProcessDualImplementation.test_cmdline_peb_false.<locals>.<lambda>r�r;r,r,r-�test_cmdline_peb_falseJsz4TestProcessDualImplementation.test_cmdline_peb_falseN)r�r�r�r�r�r,r,r,r-r�Esr�c@sPeZdZdZdd�Ze�dd��Ze�dd��Ze�dd	��Ze�d
d��Z	e�dd
��Z
e�ejj
eore��dkdd�ejj
edd�dd����Zejj
edd�dd��Zdd�Zejj
edd�dd��Zdd�Zdd�Zejj
ed d�d!d"��Zejj
e�oej�d#�d$d�e�d%d&���Z e�d'd(��Z!e�ejj
e"dd�d)d*���Z#e�ejj
e�one�$�d+kd,d�d-d.���Z%d/d0�Z&ejj
ed d�d1d2��Z'e�ejj
e(dd�d3d4���Z)e�ejj
e*dd�d5d6���Z+e�ejj
e,dd�d7d8���Z-e�d9d:��Z.d;d<�Z/d=d>�Z0e�rLd?d@�Z1dAdB�Z2dCdD�Z3dEdF�Z4dGdH�Z5dIS)J�TestModuleFunctionsLeaksz&Test leaks of psutil module functions.cCst�}|�||j�dSr")rr4r�r5r,r,r-r7Vsz&TestModuleFunctionsLeaks.test_coveragecCs|�dd��dS)NcSstjdd�S)NT��logical�rS�	cpu_countr,r,r,r-rJ^rKz9TestModuleFunctionsLeaks.test_cpu_count.<locals>.<lambda>r�r;r,r,r-�test_cpu_count\sz'TestModuleFunctionsLeaks.test_cpu_countcCs|�dd��dS)NcSstjdd�S)NFr�r�r,r,r,r-rJbrKz?TestModuleFunctionsLeaks.test_cpu_count_cores.<locals>.<lambda>r�r;r,r,r-�test_cpu_count_cores`sz-TestModuleFunctionsLeaks.test_cpu_count_corescCs|�tj�dSr")r8rSrir;r,r,r-rjdsz'TestModuleFunctionsLeaks.test_cpu_timescCs|�dd��dS)NcSstjdd�S)NT)Zpercpu)rSrir,r,r,r-rJjrKz=TestModuleFunctionsLeaks.test_per_cpu_times.<locals>.<lambda>r�r;r,r,r-�test_per_cpu_timeshsz+TestModuleFunctionsLeaks.test_per_cpu_timescCs|�tj�dSr")r8rSZ	cpu_statsr;r,r,r-�test_cpu_statslsz'TestModuleFunctionsLeaks.test_cpu_stats�arm64zskipped due to #1892r@rNcCs|�tj�dSr")r8rSZcpu_freqr;r,r,r-�
test_cpu_freqpsz&TestModuleFunctionsLeaks.test_cpu_freqrccCst��|�tj�dSr")rS�
getloadavgr8r;r,r,r-�test_getloadavgysz(TestModuleFunctionsLeaks.test_getloadavgcCs|�tj�dSr")r8rSZvirtual_memoryr;r,r,r-�test_virtual_memory�sz,TestModuleFunctionsLeaks.test_virtual_memoryz&worthless on SUNOS (uses a subprocess)cCs|�tj�dSr")r8rSZswap_memoryr;r,r,r-�test_swap_memory�sz)TestModuleFunctionsLeaks.test_swap_memorycCs$trtn|j}|jdd�|d�dS)NcSst�t���Sr")rSZ
pid_existsrWrXr,r,r,r-rJ�rKz:TestModuleFunctionsLeaks.test_pid_exists.<locals>.<lambda>ro�rr%r$r8rqr,r,r-�test_pid_exists�sz(TestModuleFunctionsLeaks.test_pid_existscCs$trtn|j}|jdd�|d�dS)NcSs
t�d�S)N�.)rS�
disk_usager,r,r,r-rJ�rKz:TestModuleFunctionsLeaks.test_disk_usage.<locals>.<lambda>ror�rqr,r,r-�test_disk_usage�sz(TestModuleFunctionsLeaks.test_disk_usagezQEMU user not supportedcCs|�tj�dSr")r8rSZdisk_partitionsr;r,r,r-�test_disk_partitions�sz-TestModuleFunctionsLeaks.test_disk_partitionsz/proc/diskstatsz3/proc/diskstats not available on this Linux versioncCs|�dd��dS)NcSstjdd�S�NF)Znowrap)rSZdisk_io_countersr,r,r,r-rJ�rKz@TestModuleFunctionsLeaks.test_disk_io_counters.<locals>.<lambda>r�r;r,r,r-�test_disk_io_counters�sz.TestModuleFunctionsLeaks.test_disk_io_counterscCs|�tj�dSr")r8rSZpidsr;r,r,r-�	test_pids�sz"TestModuleFunctionsLeaks.test_pidscCs|�dd��dS)NcSstjdd�Sr�)rSZnet_io_countersr,r,r,r-rJ�rKz?TestModuleFunctionsLeaks.test_net_io_counters.<locals>.<lambda>r�r;r,r,r-�test_net_io_counters�sz-TestModuleFunctionsLeaks.test_net_io_countersrzneed root accesscCsDtjdd�t��|�dd��Wd�n1s60YdS)Nr��r�cSstjdd�S)Nr�r�)rSr�r,r,r,r-rJ�rKz?TestModuleFunctionsLeaks.test_net_connections.<locals>.<lambda>)rSr�rr8r;r,r,r-r��sz-TestModuleFunctionsLeaks.test_net_connectionscCs"trdn|j}|jtj|d�dS)Ni@)�	tolerance)rr�r8rSZnet_if_addrs)r&r�r,r,r-�test_net_if_addrs�sz*TestModuleFunctionsLeaks.test_net_if_addrscCs|�tj�dSr")r8rSZnet_if_statsr;r,r,r-�test_net_if_stats�sz*TestModuleFunctionsLeaks.test_net_if_statscCs|�tj�dSr")r8rSZsensors_batteryr;r,r,r-�test_sensors_battery�sz-TestModuleFunctionsLeaks.test_sensors_batterycCs|�tj�dSr")r8rSZsensors_temperaturesr;r,r,r-�test_sensors_temperatures�sz2TestModuleFunctionsLeaks.test_sensors_temperaturescCs|�tj�dSr")r8rSZsensors_fansr;r,r,r-�test_sensors_fans�sz*TestModuleFunctionsLeaks.test_sensors_fanscCs|�tj�dSr")r8rSZ	boot_timer;r,r,r-�test_boot_time�sz'TestModuleFunctionsLeaks.test_boot_timecCs|�tj�dSr")r8rSZusersr;r,r,r-�
test_users�sz#TestModuleFunctionsLeaks.test_userscCs|�dd��dS)NcSs
t�d�S)NF)rSZ
_set_debugr,r,r,r-rJ�rKz9TestModuleFunctionsLeaks.test_set_debug.<locals>.<lambda>r�r;r,r,r-�test_set_debug�sz'TestModuleFunctionsLeaks.test_set_debugcCs|�tj�dSr")r8rVZwinservice_enumerater;r,r,r-�test_win_service_iter�sz.TestModuleFunctionsLeaks.test_win_service_itercCsdSr"r,r;r,r,r-�test_win_service_get�sz-TestModuleFunctionsLeaks.test_win_service_getcs&tt������|��fdd��dS)Ncs
t���Sr")rVZwinservice_query_configr,�r:r,r-rJ�rKzFTestModuleFunctionsLeaks.test_win_service_get_config.<locals>.<lambda>��nextrSZwin_service_iterr:r8r;r,r�r-�test_win_service_get_config�sz4TestModuleFunctionsLeaks.test_win_service_get_configcs&tt������|��fdd��dS)Ncs
t���Sr")rVZwinservice_query_statusr,r�r,r-rJ�rKzFTestModuleFunctionsLeaks.test_win_service_get_status.<locals>.<lambda>r�r;r,r�r-�test_win_service_get_status�sz4TestModuleFunctionsLeaks.test_win_service_get_statuscs&tt������|��fdd��dS)Ncs
t���Sr")rVZwinservice_query_descrr,r�r,r-rJ�rKzKTestModuleFunctionsLeaks.test_win_service_get_description.<locals>.<lambda>r�r;r,r�r-� test_win_service_get_description�sz9TestModuleFunctionsLeaks.test_win_service_get_descriptionN)6r�r�r�r�r7r2r�r�rjr�r�rr�r�r�platform�machinerr�rr�r�rr�r�r�rr�rrW�path�existsr�r�rr��getuidr�r�r�rr�rr�rr�r�r�r�r�r�r�r�r�r,r,r,r-r�Ss~




�


�


r�)4r��
__future__rr/rWr�rSZpsutil._commonrrrrrrZpsutil._compatr	r
Zpsutil.testsrrr
rrrrrrrrrrrrrrrrrrr Z_psplatformrVr^rLr%r2r3r�r�r�r�r�r,r,r,r-�<module>s\
66