pypy / pypy

PyPy is a very fast and compliant implementation of the Python language.
https://pypy.org
Other
1.15k stars 61 forks source link

Error Code Handling in Multiprocessing Tests #3020

Open gitlab-importer opened 5 years ago

gitlab-importer commented 5 years ago

In Heptapod by bitbucket_importer on May 26, 2019, 19:13

Created originally on Bitbucket by andrewjlawrence (Andrew Lawrence)

There is some behavior of error codes that I cannot explain in test_multiprocessing_spawn.py.

When running the tests lib-python\3\test\test_multiprocessing_spawn.py WithManagerTestLock.test_lock WithProcessesTestBarrier.test_barrier on Windows the error code leaks from test_lock into test_barrier causing test_barrier to fail.

In CPython the error codes do not leak between the tests like this.

I have also noticed that doing p _winapi.GetLastError() from pdb inside WithProcessesTestBarrier.test_barrier in CPython produces the error code from the previous test but print(_winapi.GetLastError()) in the test itself does not result in the error.

Also inserting the following code into _test_multiprocessing.py results in different behaviour on both CPython and windows when running test_multiprocessing_spawn.py WithManagerTestLock.test_lock

class ManagerMixin(object):
  def tearDownClass(cls):
        import ctypes
        ctypes.windll.kernel32.SetLastError(996)
        print(_winapi.GetLastError())
        print(ctypes.windll.kernel32.GetLastError())

The final print statement produces 0 in CPython and 996 in PyPy

gitlab-importer commented 5 years ago

In Heptapod by bitbucket_importer on May 26, 2019, 19:13

Created originally on Bitbucket by andrewjlawrence (Andrew Lawrence)

There is some behavior of error codes that I cannot explain in test_multiprocessing_spawn.py.

When running the tests lib-python\3\test\test_multiprocessing_spawn.py WithManagerTestLock.test_lock WithProcessesTestBarrier.test_barrier on Windows the error code leaks from test_lock into test_barrier causing test_barrier to fail.

In CPython the error codes do not leak between the tests like this.

I have also noticed that doing p _winapi.GetLastError() from pdb inside WithProcessesTestBarrier.test_barrier in CPython produces the error code from the previous test but print(_winapi.GetLastError()) in the test itself does not result in the error.

Also inserting the following code into _test_multiprocessing.py results in different behaviour on both CPython and windows when running test_multiprocessing_spawn.py WithManagerTestLock.test_lock

class ManagerMixin(object):
  def tearDownClass(cls):
        import ctypes
        ctypes.windll.kernel32.SetLastError(996)
        print(_winapi.GetLastError())
        print(ctypes.windll.kernel32.GetLastError())

The final print statement produces 0 in CPython and 996 in PyPy