classification
Title: python platform no child error
Type: behavior Stage: resolved
Components: Build Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, iritkatriel, sskamble619
Priority: normal Keywords:

Created on 2018-07-24 21:02 by sskamble619, last changed 2020-11-30 14:33 by christian.heimes. This issue is now closed.

Messages (3)
msg322330 - (view) Author: sachin (sskamble619) Date: 2018-07-24 21:02
We are trying to utilize librosa library for some processing. When we try to load the librosa library, python platform library is triggered via the  Numba library. Numba is trying to find the underlying OS which is installed. Function "_syscmd_uname" is triggered to find out the underlying os, but in the above function the os.popen object which is opened to determine the OS , but when the object is closed it throws a no child process error. This is mainly due to the closure of the popen object before the close fuction is called. we can get around this problem 
by catching the error and returning a default value if the closing of the popen pipeline fails

python platform.py file

def _syscmd_uname(option, default=''):

    """ Interface to the system's uname command.
    """
    if sys.platform in ('dos', 'win32', 'win16'):
        # XXX Others too ?
        return default
    try:
        f = os.popen('uname %s 2> %s' % (option, DEV_NULL))
    except (AttributeError, OSError):
        return default
    output = f.read().strip()
    rc = f.close()  # error at this place enclose in a try except statement to catrch the exception
    if not output or rc:
        return default
    else:
return output
msg382144 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-11-30 11:46
I was unable to reproduce this on Python 3. Is this issue only relevant to version 2.7?

Can you please post a complete script that shows the issue, and specify on which system you see it?
msg382152 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-11-30 14:33
The platform module no longer uses popen(). Victor replaced the broken code with subprocess in bpo-35346.
History
Date User Action Args
2020-11-30 14:33:28christian.heimessetstatus: pending -> closed

type: compile error -> behavior

nosy: + christian.heimes
messages: + msg382152
resolution: fixed
stage: resolved
2020-11-30 11:46:27iritkatrielsetstatus: open -> pending
nosy: + iritkatriel
messages: + msg382144

2018-07-24 21:02:51sskamble619create