akarneliuk / pygnmi

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

Do not keep global state for grpc_options #74

Closed sebageek closed 2 years ago

sebageek commented 2 years ago

If grpc_options is not passed to init() a default list is constructed. This argument is created once when the method is defined, thus meaning all instances of gNMIclient ever created will share it. As this list is later modified (e.g. in the case of skip_verify=True) all instances share common options. This leads to connection failures and can result in only one working GNMI connection per program launch.

For details on this type of error see also here: https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments