akarneliuk / pygnmi

The pure Python implementation of the gNMI client.
https://training.karneliuk.com
BSD 3-Clause "New" or "Revised" License
126 stars 44 forks source link

Issue with Thread Termination in gNMI Client Subscription #140

Open sai1274 opened 9 months ago

sai1274 commented 9 months ago

I created a subscription and when i do .close() on the PollSubscriber object it's not terminating the thread which it created initially. It's just going here waiting for one sec and returning https://github.com/akarneliuk/pygnmi/blob/ef224a67f58c5b9441241000f12a22b9713ed2a2/pygnmi/client.py#L1105

if i remove the timeout in .join() it never terminate.

This is the code I'm using for subscribing

from pygnmi.client import gNMIclient

server_host = 'xx.xx.xx.xx'  
server_port = 57400  
with gNMIclient(target=(server_host, server_port),username="xxxxx", password="xxxxx", insecure=True, debug=True) as client:
    client.connect()
    subscription_dict = {'subscription': [{'path': 'openconfig-interfaces:interfaces/', 'mode':'sample'}], 'mode': 'poll', 'encoding':'json'}
    subscription_ids = []
    subscription_id = client.subscribe_poll(subscribe=subscription_dict)
import pdb;pdb.set_trace()
subscription_id.close()
akarneliuk commented 8 months ago

Hey @sai1274 , PRs are welcome.

akarneliuk commented 6 months ago

Hey @sai1274 , What would be the expectation here? just trying to understand the workflow. is the problem that thread stays open within your Linux threads once the app is terminated?