Skip to content

When MacOS is updated from Homebrew any Python2 YDK application fails #837

@ygorelik

Description

@ygorelik

Current Behavior

When MacOS is updated from Homebrew, which is normal and expected behavior, any run of YDK Python2 based application fails with error:

Fatal Python error: PyThreadState_Get: no current thread

This is known and well documented issue, which has few suggested workaround processes. These solution must be tested on MacOS platform and well documented in YDK documentation along with suggested workaround.

The symptoms and workaround are also documented here.

Steps to Reproduce

Update MacOS from Homebrew using command:

$ brew update

Install ydk and IOS XR bundle:

$ pip install ydk
$ pip install ydk-models-cisco-ios-xr

Copy hello-ydk.py from below and try to run it:

$ python  hello-ydk.py

Observe the error.

Your script

# import providers, services and models
from ydk.services import CRUDService
from ydk.providers import NetconfServiceProvider
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_shellutil_oper as xr_shellutil_oper
from datetime import timedelta

def enable_logging(level):
    import logging
    log = logging.getLogger('ydk')
    log.setLevel(level)
    handler = logging.StreamHandler()
    formatter = logging.Formatter(("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
    handler.setFormatter(formatter)
    log.addHandler(handler)

if __name__ == "__main__":
    """Main execution path"""

    enable_logging(logging.INFO)
    
    # create NETCONF session
    provider = NetconfServiceProvider(address="192.168.122.169",
                                      port=830,
                                      username="admin",
                                      password="admin",
                                      protocol="ssh")
    # create CRUD service
    crud = CRUDService()

    # create system time object
    system_time = xr_shellutil_oper.SystemTime()

    # read system time from device
    system_time = crud.read(provider, system_time)

    # print system uptime
    print("System uptime is " +
          str(timedelta(seconds=system_time.uptime.uptime)))

    exit()

Logs

ANTHONYP-M-K0ZN:ydk-py-samples anthonyp$ ./hello-ydk.py 
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

System Information

YDK-0.7.3 + cisco-ios-xr bundle

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions