This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martius
Recipients gvanrossum, martius, vstinner, yselivanov
Date 2015-07-31.14:57:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1438354626.92.0.802065077035.issue24763@psf.upfronthosting.co.za>
In-reply-to
Content
An exception can be raised in SubprocessTransport.__init__() from SubprocessTransport._start() - for instance because an exception is raised in the preexec_fn callback.

In this case, the calling function never gets a reference to the transport object, and cannot close the transport. Hence, when the object is deleted, an "unclosed transport" ResourceWarning is always triggered.

Here is a test case showing this behavior:
import asyncio

loop = asyncio.get_event_loop()
try:
    loop.run_until_complete(asyncio.create_subprocess_exec('/doesntexist'))
except FileNotFoundError:
    pass
finally:
    loop.close()


I propose the attached patch as a solution, which call SubprocessTransport.close() when an exception is raised in SubprocessTransport._start() in the constructor.
History
Date User Action Args
2015-07-31 14:57:06martiussetrecipients: + martius, gvanrossum, vstinner, yselivanov
2015-07-31 14:57:06martiussetmessageid: <1438354626.92.0.802065077035.issue24763@psf.upfronthosting.co.za>
2015-07-31 14:57:06martiuslinkissue24763 messages
2015-07-31 14:57:06martiuscreate