Hi Ivan,

On Tue, Mar 23, 2021 at 9:04 AM Ivan Pozdeev via Python-Dev
<python-dev@python.org> wrote:
> I didn't quite get what the big effect is. Saving 30 milliseconds?

I started to dig into this issue while debugging a random crash on AIX
(bpo-40091). A test_threading test using fork randomly crashed on AIX.
I discovered that the crash was triggered by the logging module. It
surprised me since threading and test_threading don't use the logging
module.

"import test.support" not only loads code but also has side effects
because it runs code. Some examples:

* "import logging" calls atexit.register() and os.register_at_fork().
* "import random" calls os.register_at_fork().
* "import readline" sets SIGWINCH signal handler.

In general, it's perfectly fine in tests to import modules which have
side effects. But I'm talking about the very specific case of the
Python test suite which tests low-level Python internals, any side
effect causes multiple annoying issues and makes debugging way harder.

I'm working for years on making the Python test suite more reliable.
These side effects indirectly make tests less reliable and less
reproducible.

IMO test_threading must not test the logging module. If someone wants
to test the relationship between logging, threading and fork, a new
dedicated test should be written in test_logging. In this case, there
are already fork tests in test_logging ;-)

By the way, I'm also working on fixing these random crashes ;-) For
example, I partially fixed the AIX crash at fork in a generic way by
adding new _at_fork_reinit() methods to locks: see also the underlying
_PyThread_at_fork_reinit() function.


> Also, how is the now-split-off funcionality to be invoked? Does it require 
> two or more imports now, or it's imported on demand when one
> invokes an appropriate test.support entry?

For example, TESTFN should now be get from test.support.os_helper.

Some tests use "from test.support.os_helper import TESTFN", other
tests prefer "from test.support import os_helper" and then use
"os_helper.TESTFN".

All tests in Lib/test/ have been updated last year, you don't have to
do anything.

By the way, the test module should not be used outside Python, it's
clearly specified in its documentatioin ;-) On Fedora, the "test"
module is not installed by default, but is in a separated python3-test
package. (Another reason is to reduce the disk space.)


I hope that it gives you a better idea why these changes were made ;-)

Victor
-- 
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/OVGPFLZ762MKCGXFCXI7Y6QNR5PKJF7L/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to