Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread leak with PyEZ #1214

Open
samta93 opened this issue Nov 3, 2022 · 4 comments
Open

Thread leak with PyEZ #1214

samta93 opened this issue Nov 3, 2022 · 4 comments

Comments

@samta93
Copy link

samta93 commented Nov 3, 2022

This simple script will results in thread leak in junos device.

from jnpr.junos import Device
import time

def get_server_detail():
    dev = Device(gather_facts=False)
    dev.open()
    dev.display_xml_rpc('show version', format='text')
    dev.close()


while True:
    get_server_detail()
    time.sleep(60)

Although we are closing the connection the thread count associated with the process will keep increasing after each sleep call.

@samta93
Copy link
Author

samta93 commented Nov 9, 2022

@vnitinv Can you please review this issue?

@chidanandpujar
Copy link
Collaborator

chidanandpujar commented Nov 9, 2022

Hi ,

Monitored the script for few iterations thread count stands at 1 on off-box

from jnpr.junos import Device
import time

def get_server_detail():
    dev = Device(host='xx.xx.xx.xx', user='xyz', password='xyz', gather_facts=False)
    dev.open()
    dev.display_xml_rpc('show version', format='text')
    dev.close()


while True:
    get_server_detail()
    time.sleep(60)


Package               Version
--------------------- ------------------
bcrypt                4.0.1
cffi                  1.15.1
cryptography          38.0.3
Jinja2                3.1.2
junos-eznc            2.6.5+10.gc58107eb
lxml                  4.9.1
MarkupSafe            2.1.1
ncclient              0.6.13
netaddr               0.8.0
paramiko              2.12.0
pip                   21.1.3
pycparser             2.21
PyNaCl                1.5.0
pyparsing             3.0.9
pyserial              3.5
PyYAML                6.0
scp                   0.14.4
setuptools            56.0.0
six                   1.16.0
transitions           0.9.0
yamlordereddictloader 0.4.0

(venv) root@nms5:~/pyez_1213_thread_safety# cat /proc/13778/status | grep Threads
Threads:	1
(venv) root@nms5:~/pyez_1213_thread_safety# cat /proc/13778/status | grep Threads
Threads:	1
(venv) root@nms5:~/pyez_1213_thread_safety# cat /proc/13778/status | grep Threads
Threads:	1
(venv) root@nms5:~/pyez_1213_thread_safety# cat /proc/13778/status | grep Threads
Threads:	1
(venv) root@nms5:~/pyez_1213_thread_safety# cat /proc/13778/status | grep Threads
Threads:	1
(venv) root@nms5:~/pyez_1213_thread_safety# cat /proc/13778/status | grep Threads
Threads:	1
(venv) root@nms5:~/pyez_1213_thread_safety# cat /proc/13778/status | grep Threads
Threads:	1
(venv) root@nms5:~/pyez_1213_thread_safety# cat /proc/13778/status | grep Threads
Threads:	1
(venv) root@nms5:~/pyez_1213_thread_safety# cat /proc/13778/status | grep Threads
Threads:	1
(venv) root@nms5:~/pyez_1213_thread_safety# cat /proc/13778/status | grep Threads
Threads:	1
(venv) root@nms5:~/pyez_1213_thread_safety# cat /proc/13778/status | grep Threads
Threads:	1

Thanks & Regards
Chidanand

@chidanandpujar chidanandpujar self-assigned this Nov 9, 2022
@chidanandpujar
Copy link
Collaborator

following is the status of threads .

PID TID COMM TDNAME CPU PRI STATE WCHAN
12150 100212 cscript - -1 141 sleep select
12150 100325 cscript - -1 152 sleep usem
12150 100326 cscript - -1 129 sleep usem
12150 100327 cscript - -1 127 sleep usem
12150 100328 cscript - -1 127 sleep usem
12150 100329 cscript - -1 129 sleep usem
12150 100330 cscript - -1 129 sleep usem
12150 100331 cscript - -1 129 sleep usem
12150 100332 cscript - -1 129 sleep usem
12150 100333 cscript - -1 129 sleep usem
12150 100334 cscript - -1 129 sleep usem
12150 100335 cscript - -1 129 sleep usem
12150 100336 cscript - -1 129 sleep usem
12150 100337 cscript - -1 129 sleep usem
12150 100338 cscript - -1 129 sleep usem
12150 100339 cscript - -1 127 sleep usem
12150 100340 cscript - -1 129 sleep usem
12150 100341 cscript - -1 128 sleep usem
12150 100342 cscript - -1 129 sleep usem
12150 100343 cscript - -1 129 sleep usem
12150 100344 cscript - -1 127 sleep usem
12150 100345 cscript - -1 129 sleep usem
12150 100346 cscript - -1 129 sleep usem
12150 100347 cscript - -1 129 sleep usem
12150 100348 cscript - -1 129 sleep usem
12150 100349 cscript - -1 129 sleep usem
12150 100350 cscript - -1 129 sleep usem
12150 100351 cscript - -1 127 sleep usem
12150 100352 cscript - -1 129 sleep usem
12150 100353 cscript - -1 129 sleep usem
12150 100354 cscript - -1 129 sleep usem
12150 100355 cscript - -1 128 sleep usem
12150 100356 cscript - -1 129 sleep usem
12150 100357 cscript - -1 129 sleep usem
12150 100358 cscript - -1 129 sleep usem
12150 100359 cscript - -1 129 sleep usem
12150 100360 cscript - -1 129 sleep usem
12150 100361 cscript - -1 129 sleep usem
12150 100362 cscript - -1 129 sleep usem
12150 100363 cscript - -1 129 sleep usem

12150 100212 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_timedwait_sig _cv_timedwait_sig_sbt seltdwait kern_select sys_select swi_handler swi_exit
12150 100325 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100326 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100327 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100328 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100329 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100330 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100331 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100332 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100333 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100334 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100335 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100336 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100337 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100338 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100339 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100340 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100341 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100342 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100343 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100344 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100345 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100346 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100347 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100348 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100349 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100350 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100351 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100352 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100353 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100354 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100355 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100356 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100357 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100358 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100359 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100360 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100361 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100362 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100363 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit
12150 100364 cscript - sched_switch mi_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep __umtx_op_sem2_wait swi_handler swi_exit

@samta93
Copy link
Author

samta93 commented Jan 20, 2023

@chidanandpujar did you find the root cause?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants