parameters: (cleaner, database_name)
docstring: Deletes all glue tables from the client before the database is deleted. It will construct a list of resources,
      delete them, then wait for each deletion.
      :param cleaner: A Cleaner object from the main cleanup.py script
      :param database_name: The name of the glue database that the tables live under
      :return: None
docstring_summary: Deletes all glue tables from the client before the database is deleted. It will construct a list of resources,
      delete them, then wait for each deletion.
      :param cleaner: A Cleaner object from the main cleanup.py script
      :param database_name: The name of the glue database that the tables live under
      :return: None
docstring_tokens: Deletes all glue tables from the client before the database is deleted . It will construct a list of resources delete them then wait for each deletion . : param cleaner : A Cleaner object from the main cleanup . py script : param database_name : The name of the glue database that the tables live under : return : None
function: def _delete_glue_tables(cleaner, database_name):
      """
      Deletes all glue tables from the client before the database is deleted. It will construct a list of resources,
      delete them, then wait for each deletion.
      :param cleaner: A Cleaner object from the main cleanup.py script
      :param database_name: The name of the glue database that the tables live under
      :return: None
      """
      print('\n\nlooking for Glue tables with names starting with one of {}'.format(cleaner.describe_prefixes()))
      params = {'DatabaseName': database_name}
      glue_table_name_list = []
      # Construct list
      try:
          for result in cleanup_utils.paginate(cleaner.glue.get_tables, params, 'NextToken', 'NextToken'):
              for table_info in result['TableList']:
                  table_name = table_info['Name']
                  if cleaner.has_prefix(table_name):
                      print('  found glue table {}'.format(table_name))
                      glue_table_name_list.append(table_name)
      except KeyError as e:
          print("      ERROR: Unexpected KeyError while deleting glue tables. {}".format(exception_utils.message(e)))
          return
      except ClientError as e:
          print("      ERROR: Unexpected error for paginator for the glue client. {}".format(exception_utils.message(e)))
          return
  
      # Delete glue crawlers
      for table_name in glue_table_name_list:
          print('  deleting table {}'.format(table_name))
          try:
              cleaner.glue.delete_table(Name=table_name, DatabaseName=database_name)
          except ClientError as e:
              if e.response["Error"]["Code"] == "TooManyRequestsException":
                  print('    too many requests, sleeping...')
                  time.sleep(cleaner.wait_interval)
              else:
                  print('      ERROR: Failed to delete table {0} due to {1}'.format(table_name,
                                                                                    exception_utils.message(e)))
                  cleaner.add_to_failed_resources("glue", table_name)
  
      # Wait for deletion
      for table_name in glue_table_name_list:
          try:
              cleanup_utils.wait_for(lambda: not __glue_table_exists(cleaner, database_name, table_name),
                                     attempts=cleaner.wait_attempts,
                                     interval=cleaner.wait_interval,
                                     timeout_exception=cleanup_utils.WaitError)
          except cleanup_utils.WaitError:
              print('      ERROR. Glue crawler {0} was not deleted after timeout'.format(table_name))
              cleaner.add_to_failed_resources("glue", table_name)
          except ClientError as e:
              if e.response["Error"]["Code"] == "TooManyRequestsException":
                  print('    too many requests, sleeping...')
                  time.sleep(cleaner.wait_interval)
              else:
                  print("      ERROR: Unexpected error occurred waiting for glue table {0} to delete due to {1}"
                        .format(table_name, exception_utils.message(e)))
                  cleaner.add_to_failed_resources("glue", table_name)
function_tokens: def _delete_glue_tables ( cleaner , database_name ) : print ( '\n\nlooking for Glue tables with names starting with one of {}' . format ( cleaner . describe_prefixes ( ) ) ) params = { 'DatabaseName' : database_name } glue_table_name_list = [ ] # Construct list try : for result in cleanup_utils . paginate ( cleaner . glue . get_tables , params , 'NextToken' , 'NextToken' ) : for table_info in result [ 'TableList' ] : table_name = table_info [ 'Name' ] if cleaner . has_prefix ( table_name ) : print ( '  found glue table {}' . format ( table_name ) ) glue_table_name_list . append ( table_name ) except KeyError as e : print ( "      ERROR: Unexpected KeyError while deleting glue tables. {}" . format ( exception_utils . message ( e ) ) ) return except ClientError as e : print ( "      ERROR: Unexpected error for paginator for the glue client. {}" . format ( exception_utils . message ( e ) ) ) return # Delete glue crawlers for table_name in glue_table_name_list : print ( '  deleting table {}' . format ( table_name ) ) try : cleaner . glue . delete_table ( Name = table_name , DatabaseName = database_name ) except ClientError as e : if e . response [ "Error" ] [ "Code" ] == "TooManyRequestsException" : print ( '    too many requests, sleeping...' ) time . sleep ( cleaner . wait_interval ) else : print ( '      ERROR: Failed to delete table {0} due to {1}' . format ( table_name , exception_utils . message ( e ) ) ) cleaner . add_to_failed_resources ( "glue" , table_name ) # Wait for deletion for table_name in glue_table_name_list : try : cleanup_utils . wait_for ( lambda : not __glue_table_exists ( cleaner , database_name , table_name ) , attempts = cleaner . wait_attempts , interval = cleaner . wait_interval , timeout_exception = cleanup_utils . WaitError ) except cleanup_utils . WaitError : print ( '      ERROR. Glue crawler {0} was not deleted after timeout' . format ( table_name ) ) cleaner . add_to_failed_resources ( "glue" , table_name ) except ClientError as e : if e . response [ "Error" ] [ "Code" ] == "TooManyRequestsException" : print ( '    too many requests, sleeping...' ) time . sleep ( cleaner . wait_interval ) else : print ( "      ERROR: Unexpected error occurred waiting for glue table {0} to delete due to {1}" . format ( table_name , exception_utils . message ( e ) ) ) cleaner . add_to_failed_resources ( "glue" , table_name )