in azure_functions_worker/bindings/shared_memory_data_transfer/file_accessor_unix.py [0:0]
def _open_mem_map_file(self, mem_map_name: str) -> Optional[BufferedRandom]:
"""
Get the file descriptor of an existing memory map.
Returns the BufferedRandom stream to the file.
"""
# Iterate over all the possible directories where the memory map could
# be present and try to open it.
for temp_dir in self.valid_dirs:
file_path = os.path.join(temp_dir, mem_map_name)
if os.path.exists(file_path):
try:
fd = open(file_path, 'r+b')
return fd
except Exception as e:
logger.error('Cannot open file %s - %s', file_path, e,
exc_info=True)
# The memory map was not found in any of the known directories
logger.error(
'Cannot open memory map %s in any of the following directories: '
'%s',
mem_map_name, self.valid_dirs)
return None