core/tests/util
J. Nick Koston 03eea7bd3f
Avoid subprocess memory copy when c library supports posix_spawn (#87958)
* use posix spawn on alpine

* Avoid subprocess memory copy when c library supports posix_spawn

By default python 3.10 will use the fork() which has to
copy all the memory of the parent process (in our case
this can be huge since Home Assistant core can use
hundreds of megabytes of RAM). By using posix_spawn
this is avoided.

In python 3.11 vfork will also be available
https://github.com/python/cpython/issues/80004#issuecomment-1093810689
https://github.com/python/cpython/pull/11671 but we won't
always be able to use it and posix_spawn is considered safer
https://bugzilla.kernel.org/show_bug.cgi?id=215813#c14

The subprocess library doesn't know about musl though
even though it supports posix_spawn https://git.musl-libc.org/cgit/musl/log/src/process/posix_spawn.c
so we have to teach it since it only has checks for glibc
1b736838e6/Lib/subprocess.py (L745)

The constant is documented as being able to be flipped here:
https://docs.python.org/3/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn

* Avoid subprocess memory copy when c library supports posix_spawn

By default python 3.10 will use the fork() which has to
copy memory of the parent process (in our case
this can be huge since Home Assistant core can use
hundreds of megabytes of RAM). By using posix_spawn
this is avoided and subprocess creation does not
get discernibly slow the larger the Home Assistant
python process grows.

In python 3.11 vfork will also be available
https://github.com/python/cpython/issues/80004#issuecomment-1093810689
https://github.com/python/cpython/pull/11671 but we won't
always be able to use it and posix_spawn is considered safer
https://bugzilla.kernel.org/show_bug.cgi?id=215813#c14

The subprocess library doesn't know about musl though
even though it supports posix_spawn https://git.musl-libc.org/cgit/musl/log/src/process/posix_spawn.c
so we have to teach it since it only has checks for glibc
1b736838e6/Lib/subprocess.py (L745)

The constant is documented as being able to be flipped here:
https://docs.python.org/3/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn

* missed some

* adjust more tests

* coverage
2023-02-13 09:02:51 -05:00
..
yaml Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
__init__.py
test_aiohttp.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_async.py Add typing to tests with single hass argument (2) (#87675) 2023-02-08 08:51:43 +01:00
test_color.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_distance.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_dt.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_enum.py Add enum util (#87082) 2023-02-01 15:00:27 +01:00
test_executor.py Fix deadlock at shutdown with python 3.9 (#52613) 2021-07-07 09:23:24 +02:00
test_file.py Use atomicwrites for mission critical core files (#59606) 2021-11-15 11:19:31 +01:00
test_init.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_json.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_location.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_logging.py Add typing to tests with single hass argument (2) (#87675) 2023-02-08 08:51:43 +01:00
test_network.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_package.py Avoid subprocess memory copy when c library supports posix_spawn (#87958) 2023-02-13 09:02:51 -05:00
test_percentage.py Add return type to async tests without arguments (#87612) 2023-02-07 10:26:56 +01:00
test_pressure.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_process.py Add return type to async tests without arguments (#87612) 2023-02-07 10:26:56 +01:00
test_read_only_dict.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_speed.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_temperature.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00
test_thread.py Add typing to tests with single hass argument (2) (#87675) 2023-02-08 08:51:43 +01:00
test_timeout.py Add typing to tests with single hass argument (2) (#87675) 2023-02-08 08:51:43 +01:00
test_ulid.py Add return type to async tests without arguments (#87612) 2023-02-07 10:26:56 +01:00
test_unit_conversion.py Add Mega Joule as valid unit of energy (#86055) 2023-01-25 14:13:42 +01:00
test_unit_system.py Update unit system unit conversions (#87632) 2023-02-08 10:52:54 +01:00
test_uuid.py Add return type to async tests without arguments (#87612) 2023-02-07 10:26:56 +01:00
test_variance.py Add PrusaLink integration (#77429) 2022-08-29 20:45:27 -04:00
test_volume.py Add return type to tests without arguments (#87613) 2023-02-07 14:20:06 +01:00