in docker_images/pythonv2/wrapper/python_glue/internal_glue_factory.py [0:0]
def create_glue_object(object_type, interface_type):
if object_type not in valid_object_types:
raise ValueError(
"object_type {} invalid. only {} are accepted".format(
object_type, valid_object_types
)
)
if interface_type not in valid_interface_types:
raise ValueError(
"interface_type {} invalid. only {} are accepted".format(
interface_type, valid_interface_types
)
)
if internal_control_glue.do_async:
object_type = "async_" + object_type
else:
object_type = "sync_" + object_type
logger.info("making {} object with {}".format(object_type, interface_type))
if object_type == sync_device:
logger.info("Creating DeviceGlue")
obj = InternalDeviceGlueSync()
elif object_type == async_device:
logger.info("Creating DeviceGlueAsync")
obj = InternalDeviceGlueAsync()
elif object_type == sync_module:
logger.info("Creating ModuleGlue")
obj = InternalModuleGlueSync()
elif object_type == async_module:
logger.info("Creating ModuleGlueAsync")
obj = InternalModuleGlueAsync()
else:
assert False
if interface_type.startswith("async_"):
# async glue has some sync methods (connection_status.py) that need to be wrapped,
# so we call this for sync and async glue both
logger.info("Wrapping sync methods in async facade")
wrap_sync_in_async.wrap_object(obj)
if interface_type.startswith("sync_") and object_type.startswith("async_"):
# only wrap async in sync if we're using async glue. sync glue doesn't have
# any async methods.
logger.info("Wrapping async methods in sync facade")
wrap_async_in_sync.wrap_object(obj)
return obj