KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums PyKX pykx incompatible with subprocess and multiprocess – core dumps Re: pykx incompatible with subprocess and multiprocess – core dumps

  • kshepherd

    Member
    June 19, 2023 at 12:00 am

    This has to do with the fact that PyKX uses a few environment variables to stop certain pieces from being loaded twice if it is reimported. The parent process loads PyKX and the env vars are set, when the child process is created these env vars are passed along to the child process, which causes PyKX in the child process to only partially load and segfault.

    This can be fixed by loading PyKX in the parent process after the child process is spawned.

    parent.py

     

    print("parent start")   
    import subprocess  
    proc=subprocess.Popen(     ['/a/stor164ncs2.new-york.ms.com/sc34770/s180992/hodgidav/myenv/bin/python','child.py'],     stdout=subprocess.PIPE,     stderr=subprocess.PIPE ) 
    import pykx # import PyKX after spawning the child process 
    proc.communicate() 
    print(proc.wait())  
    print("parent end")  
    import sys  
    sys.exit(69)