MCPcopy
hub / github.com/saltstack/salt / update_lib

Method update_lib

tests/unit/test_loader.py:907–925  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

905 remove_bytecode(self.module_path)
906
907 def update_lib(self):
908 self.lib_count += 1
909 for modname in list(sys.modules):
910 if modname.startswith(self.module_name):
911 del sys.modules[modname]
912 with salt.utils.files.fopen(self.lib_path, "wb") as fh:
913 fh.write(
914 salt.utils.stringutils.to_bytes(
915 submodule_lib_template.format(count=self.lib_count)
916 )
917 )
918 fh.flush()
919 os.fsync(fh.fileno()) # flush to disk
920
921 # pyc files don't like it when we change the original quickly
922 # since the header bytes only contain the timestamp (granularity of seconds)
923 # TODO: don't write them? Is *much* slower on re-load (~3x)
924 # https://docs.python.org/2/library/sys.html#sys.dont_write_bytecode
925 remove_bytecode(self.lib_path)
926
927 def rm_lib(self):
928 for modname in list(sys.modules):

Callers 3

test_basicMethod · 0.95
test_reloadMethod · 0.95

Calls 6

remove_bytecodeFunction · 0.85
formatMethod · 0.80
listFunction · 0.50
writeMethod · 0.45
flushMethod · 0.45
filenoMethod · 0.45

Tested by

no test coverage detected