Handle teardown race, add comment about shm subdirs

incremental_update_paths
Tyler Goodlet 2022-05-24 10:36:17 -04:00
parent bbe1ff19ef
commit 1b38628b09
1 changed files with 10 additions and 1 deletions

View File

@ -98,7 +98,12 @@ class SharedInt:
if _USE_POSIX:
# We manually unlink to bypass all the "resource tracker"
# nonsense meant for non-SC systems.
shm_unlink(self._shm.name)
name = self._shm.name
try:
shm_unlink(name)
except FileNotFoundError:
# might be a teardown race here?
log.warning(f'Shm for {name} already unlinked?')
class _Token(BaseModel):
@ -536,6 +541,10 @@ def attach_shm_array(
if key in _known_tokens:
assert _Token.from_msg(_known_tokens[key]) == token, "WTF"
# XXX: ugh, looks like due to the ``shm_open()`` C api we can't
# actually place files in a subdir, see discussion here:
# https://stackoverflow.com/a/11103289
# attach to array buffer and view as per dtype
shm = SharedMemory(name=key)
shmarr = np.ndarray(