Skip to content

Commit

Permalink
Fix the remaining failing test on Python 3.4
Browse files Browse the repository at this point in the history
zdrun.py gets unhappy if it is spawned with no open file descriptors: it
creates a master socket as fd 1 and then proptly os.dup2's it out of
existence with the transcript pipe.
  • Loading branch information
mgedmin committed Mar 22, 2014
1 parent 804da73 commit ff5287c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/zdaemon/tests/parent.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,22 @@ def main():
def shutup():
os.close(0)
sys.stdin = sys.__stdin__ = open("/dev/null")
try: # PEP 446, Python >= 3.4
os.set_inheritable(sys.stdin.fileno(), True)
except AttributeError:
pass
os.close(1)
sys.stdout = sys.__stdout__ = open("/dev/null", "w")
try: # PEP 446, Python >= 3.4
os.set_inheritable(sys.stdout.fileno(), True)
except AttributeError:
pass
os.close(2)
sys.stderr = sys.__stderr__ = open("/dev/null", "w")
try: # PEP 446, Python >= 3.4
os.set_inheritable(sys.stderr.fileno(), True)
except AttributeError:
pass

if __name__ == '__main__':
main()

7 comments on commit ff5287c

@tseaver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice diagnosis / fix!

@tseaver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, tests are still failing for me under Python 3.4.0:

$ uname -srvmpio
Linux 3.2.0-60-generic #91-Ubuntu SMP Wed Feb 19 03:54:44 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/debian_version 
wheezy/sid
$ python3.4 -c "import sys; print(sys.version)"
3.4.0 (default, Mar 17 2014, 14:53:22) 
[GCC 4.6.3]
GLOB sdist-make: $ZF/Zope/zdaemon/setup.py
py34 recreate: $ZF/Zope/zdaemon/.tox/py34
py34 installdeps: zc.customdoctests, zope.testing, zope.testrunner, manuel, mock
py34 inst: $ZF/Zope/zdaemon/.tox/dist/zdaemon-4.0.1dev.zip
py34 runtests: PYTHONHASHSEED='1407244458'
py34 runtests: commands[0] | python setup.py test -q
running test
running egg_info
writing src/zdaemon.egg-info/PKG-INFO
writing requirements to src/zdaemon.egg-info/requires.txt
writing dependency_links to src/zdaemon.egg-info/dependency_links.txt
writing entry points to src/zdaemon.egg-info/entry_points.txt
writing top-level names to src/zdaemon.egg-info/top_level.txt
reading manifest file 'src/zdaemon.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'src/zdaemon.egg-info/SOURCES.txt'
running build_ext
...............................................F..............
======================================================================
FAIL: testRunIgnoresParentSignals (zdaemon.tests.testzdrun.ZDaemonTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "$ZF/Zope/zdaemon/src/zdaemon/tests/testzdrun.py", line 235, in testRunIgnoresParentSignals
    "spawned process failed to start in a minute")
AssertionError: False is not true : spawned process failed to start in a minute

----------------------------------------------------------------------
Ran 62 tests in 152.287s

FAILED (failures=1)

@mgedmin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the python3.4-pep446 branch? I get passing tests using tox -e py34 with

$ python3.4 -c "import sys; print(sys.version)"
3.4.0 (default, Mar 21 2014, 03:04:12) 
[GCC 4.8.1]

@tseaver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crap! I though you had merged that to master. Can you re-push that branch (I think I deleted it)?

@tseaver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind -- looks like you saved me already :).

@tseaver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgedmin did we lose this fix? I can't find a PR (open or closed) that refers to this branch?

@mgedmin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably committed it directly to master. It's right there in the current codebase: https://github.com/zopefoundation/zdaemon/blob/master/src/zdaemon/tests/parent.py#L40

Please sign in to comment.