def get_locked_port_and_binding(context, port_id):
 try:
  port = context.session.query(models_v2.Port).enable_eagerloads(False).filter_by(id=port_id).with_lockmode('update').one()
  binding = context.session.query(models.PortBinding).enable_eagerloads(False).filter_by(port_id=port_id).with_lockmode('update').one()
  return (port, binding)
 except exc.NoResultFound:
  return (None, None)

def get_locked_port_and_binding ( context , port_id ) : try : port = context . session . query ( models_v2 . Port ) . enable_eagerloads ( False ) . filter_by ( id = port_id ) . with_lockmode ( 'update' ) . one ( ) binding = context . session . query ( models . PortBinding ) . enable_eagerloads ( False ) . filter_by ( port_id = port_id ) . with_lockmode ( 'update' ) . one ( ) return ( port , binding ) except exc . NoResultFound : return ( None , None )
get port and port binding records for update within transaction .