Exemplo n.º 1
0
 def create_device(self, workflow_context, device_id):
     workflow_exec_id = workflow_context['workflow_execution_id']
     logger.info('Creating app instance for workflow {}, device {}'.format(workflow_exec_id, device_id))
     redis_key = ActionExecution.format_app_instance_key(workflow_exec_id, device_id)
     app_class = get_app(app_name)
     if not redis_cache.cache.sismember(app_instance_set_name, redis_key):
         # If workflows become parallelized, this will need to be locked
         logger.info('Creating new app instance')
         app_instance = app_class(app_name, device_id, workflow_context)
         redis_cache.cache.sadd(app_instance_set_name, redis_key)
         return app_instance
     else:
         logger.debug('Using existing app instance')
         return App.from_cache(app_name, device_id, workflow_context)