in azure_functions_worker/bindings/meta.py [0:0]
def _can_transfer_over_shmem(shmem_mgr: SharedMemoryManager,
is_function_data_cache_enabled: bool,
datum: datumdef.Datum):
"""
If shared memory is enabled and supported for the given datum, try to
transfer to host over shared memory as a default.
If caching is enabled, then also check if this type is supported - if so,
transfer over shared memory.
In case of caching, some conditions like object size may not be
applicable since even small objects are also allowed to be cached.
"""
if not shmem_mgr.is_enabled():
# If shared memory usage is not enabled, no further checks required
return False
if shmem_mgr.is_supported(datum):
# If transferring this object over shared memory is supported, do so.
return True
if is_function_data_cache_enabled and _does_datatype_support_caching(datum):
# If caching is enabled and this object can be cached, transfer over
# shared memory (since the cache uses shared memory).
# In this case, some requirements (like object size) for using shared
# memory may be ignored since we want to support caching of small
# objects (those that have sizes smaller that the minimum we transfer
# over shared memory when the cache is not enabled) as well.
return True
return False