cdae2fc61c0a4e03c2dee7321c91a42aa1ebdfc0
hiram
  Mon Sep 9 15:43:17 2019 -0700
now getting hgTables into the earlyBotCheck() game and fixup earlyBotCheck() to honor the exception list and default to a delay fraction value of 1.0 refs #23217

diff --git src/hg/hgTables/hgTables.c src/hg/hgTables/hgTables.c
index 9bc02b8..5e8d1e1 100644
--- src/hg/hgTables/hgTables.c
+++ src/hg/hgTables/hgTables.c
@@ -57,30 +57,34 @@
 struct cart *cart;	/* This holds cgi and other variables between clicks. */
 struct hash *oldVars;	/* The cart before new cgi stuff added. */
 char *genome;		/* Name of genome - mouse, human, etc. */
 char *database;		/* Current genome database - hg17, mm5, etc. */
 char *freezeName;	/* Date of assembly. */
 struct grp *fullGroupList;	/* List of all groups. */
 struct grp *curGroup;	/* Currently selected group. */
 struct trackDb *fullTrackList;	/* List of all tracks in database. */
 struct hash *fullTableToTdbHash;        /* All tracks and subtracks keyed by tdb->table field. */
 struct trackDb *curTrack;	/* Currently selected track. */
 char *curTable;		/* Currently selected table. */
 struct joiner *allJoiner;	/* Info on how to join tables. */
 
 static struct pipeline *compressPipeline = (struct pipeline *)NULL;
 
+static boolean issueBotWarning = FALSE;
+#define warnMs 10000    /* warning at 10 to 20 second delay */
+#define exitMs 20000    /* error 429 Too Many Requests after 20+ second delay */
+
 char *gsTemp = NULL;
 int saveStdout = -1;
 
 /* --------------- HTML Helpers ----------------- */
 
 void hPrintSpaces(int count)
 /* Print a number of non-breaking spaces. */
 {
 int i;
 for (i=0; i<count; ++i)
     hPrintf("&nbsp;");
 }
 
 static void stripHtmlTags(char *text)
 /* remove HTML tags from text string, replacing in place by moving
@@ -168,31 +172,31 @@
 static void vaHtmlOpen(char *format, va_list args)
 /* Start up a page that will be in html format. */
 {
 puts("Content-Type:text/html\n");
 cartVaWebStart(cart, database, format, args);
 pushWarnHandler(errAbortHandler);
 }
 
 void htmlOpen(char *format, ...)
 /* Start up a page that will be in html format. */
 {
 va_list args;
 va_start(args, format);
 vaHtmlOpen(format, args);
 va_end(args);
-hgBotDelay();
+// hgBotDelay(); function is now in earlyBotCheck() at the start of main()
 }
 
 void htmlClose()
 /* Close down html format page. */
 {
 popWarnHandler();
 cartWebEnd();
 }
 
 
 void explainWhyNoResults(FILE *f)
 /* Put up a little explanation to user of why they got nothing. */
 {
 if (f == NULL)
     f = stdout;
@@ -222,31 +226,34 @@
 {
 char *script = cgiScriptName();
 if (script != NULL)
     return script;
 else
     return hgTablesName();
 }
 
 
 void textOpen()
 /* Start up page in text format. (No need to close this).
  *	In case of pipeline output to a compressor, it is closed
  *	at main() exit.
  */
 {
-hgBotDelayNoWarn();  // delay but suppress warning at 10-20 sec delay level because this is not html output.
+
+// hgBotDelay function is now in earlyBotCheck() at the start of main(), and in
+// this case, the issueBotWarning flag is ignored to avoid any output here
+// hgBotDelayNoWarn();  // delay but suppress warning at 10-20 sec delay level because this is not html output.
 char *fileName = textOutSanitizeHttpFileName(cartUsualString(cart, hgtaOutFileName, ""));
 char *compressType = cartUsualString(cart, hgtaCompressType,
 				     textOutCompressNone);
 
 if (doGenomeSpace())
     {
     char hgsid[64];
     struct tempName tn;
     safef(hgsid, sizeof(hgsid), "%s", cartSessionId(cart));
     trashDirFile(&tn, "genomeSpace", hgsid, ".tmp");
     gsTemp = cloneString(tn.forCgi);
     fileName = gsTemp;
     }
 
 compressPipeline = textOutInit(fileName, compressType, &saveStdout);
@@ -1761,26 +1768,27 @@
 
 	gsTemp = NULL;
 	}	
     }
 
 
 /* Save variables. */
 cartCheckout(&cart);
 }
 
 int main(int argc, char *argv[])
 /* Process command line. */
 {
 
 long enteredMainTime = clock1000();
+issueBotWarning = earlyBotCheck(enteredMainTime, "hgTables", 1.5, warnMs, exitMs);
 
 pushCarefulMemHandler(LIMIT_2or6GB);
 htmlPushEarlyHandlers(); /* Make errors legible during initialization. */
 cgiSpoof(&argc, argv);
 
 hgTables();
 
 cgiExitTime("hgTables", enteredMainTime);
 
 return 0;
 }