py icon indicating copy to clipboard operation
py copied to clipboard

Expand conditions for recognizing main process

Open DWesl opened this issue 5 years ago • 2 comments
trafficstars

Fork failures are not uncommon on Cygwin, which causes an exception in the constructor. Unfortunately, cleaning up the partially-initialized instance calls the __del__ method, which then raises another exception because self.pid never got set. This change should prevent the second exception.

Another option is to change it to

if getattr(self, "pid", None) is not None:

DWesl avatar Aug 23 '20 22:08 DWesl

Hi @DWesl,

Am I correct that this is a bug report by way of pytest-forked, which uses py.process? I'm asking because, given that the py library is deprecated, a better outcome would be to update pytest-forked and other projects to not use py.process. The usual process is to copy/paste the relevant py code, and simplify it for the given use case.

bluetech avatar Aug 24 '20 08:08 bluetech

I think testing this would require mocking os.fork to raise an exception, which is not something I know how to do. I'll need a bit to research that.

This was uncovered while running pytest-forked. I'm preparing another PR for them and can move this file to pytest-forked as part of that.

DWesl avatar Aug 24 '20 10:08 DWesl