MCPcopy Index your code
hub / github.com/python/cpython / in_systemd_nspawn_sync_suppressed

Function in_systemd_nspawn_sync_suppressed

Lib/test/support/__init__.py:3151–3181  ·  view source on GitHub ↗

Test whether the test suite is runing in systemd-nspawn with ``--suppress-sync=true``. This can be used to skip tests that rely on ``fsync()`` calls and similar not being intercepted.

()

Source from the content-addressed store, hash-verified

3149
3150
3151def in_systemd_nspawn_sync_suppressed() -> bool:
3152 """
3153 Test whether the test suite is runing in systemd-nspawn
3154 with ``--suppress-sync=true``.
3155
3156 This can be used to skip tests that rely on ``fsync()`` calls
3157 and similar not being intercepted.
3158 """
3159
3160 if not hasattr(os, "O_SYNC"):
3161 return False
3162
3163 try:
3164 with open("/run/systemd/container", "rb") as fp:
3165 if fp.read().rstrip() != b"systemd-nspawn":
3166 return False
3167 except FileNotFoundError:
3168 return False
3169
3170 # If systemd-nspawn is used, O_SYNC flag will immediately
3171 # trigger EINVAL. Otherwise, ENOENT will be given instead.
3172 import errno
3173 try:
3174 fd = os.open(__file__, os.O_RDONLY | os.O_SYNC)
3175 except OSError as err:
3176 if err.errno == errno.EINVAL:
3177 return True
3178 else:
3179 os.close(fd)
3180
3181 return False
3182
3183def run_no_yield_async_fn(async_fn, /, *args, **kwargs):
3184 coro = async_fn(*args, **kwargs)

Callers 1

Calls 5

openFunction · 0.50
rstripMethod · 0.45
readMethod · 0.45
openMethod · 0.45
closeMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…