mirror of
https://github.com/certbot/certbot.git
synced 2026-03-28 21:33:27 -04:00
When certbot is executing, several resources are opened. It is typically file handles and locks on them. Of course, theses resources need to be cleanup. It is done in Certbot by registering cleanup functions through atexit module, that ensures theses functions will be called when Certbot exit. This allow to not care about resource cleanup everywhere in the code, as it is processed globally. The problem with atexit is it cleanup functions are called when the Python program exit. If the program is Certbot itself when used, this is Pytest in unit test execution. So during a unit test execution, cleanup is not called after a test and before its tearDown, but when Pytest exit, so way after tests and their respective tearDown. But many tearDown implies to delete folders where this kind of resources are hold. This is never a problem on Linux, thanks to its non-blocking file handling. It is usually not a problem on Windows, despite its blocking approach. But if the tearDown requires folder cleanup, exceptions are raised, and currently hidden as warnings. There is currently 504 exceptions of this type in Certbot core tests on Windows. This PR starts to correct this situation. To do so, some of the functions cleanup normally called through atexit, are explicitly called as part of the tearDown process of relevant test classes, before directory removal is done. Theses situations come all from the certbot.tests.util.TempDirTestCase, so the code is in this specific tearDown process. As a consequence, exceptions drop from 504 to 64. Then there are still a significant part of them, that will be handled in later mitigation. * Call atexit handlers before test tearDown to reduce errors on Windows * Clear locks dict after global releasing execution * Remove last tearDown errors. * Clean out mock on open. * Remove a test * Reenable some tests |
||
|---|---|---|
| .. | ||
| display | ||
| plugins | ||
| tests | ||
| .gitignore | ||
| __init__.py | ||
| account.py | ||
| achallenges.py | ||
| auth_handler.py | ||
| cert_manager.py | ||
| cli.py | ||
| client.py | ||
| compat.py | ||
| configuration.py | ||
| constants.py | ||
| crypto_util.py | ||
| eff.py | ||
| error_handler.py | ||
| errors.py | ||
| hooks.py | ||
| interfaces.py | ||
| lock.py | ||
| log.py | ||
| main.py | ||
| notify.py | ||
| ocsp.py | ||
| renewal.py | ||
| reporter.py | ||
| reverter.py | ||
| ssl-dhparams.pem | ||
| storage.py | ||
| updater.py | ||
| util.py | ||