diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-10-02 14:56:59 -0400 | 
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-10-02 14:56:59 -0400 | 
| commit | f6c504630ecfa38c1516123019bdf67b921f1107 (patch) | |
| tree | 597b69dcf3f2f3ac94bc5fd164a81a44dfb51336 | |
| parent | 4b948ef52add8c3a93aef6fd38a3928ccf4e36d7 (diff) | |
| download | stasis-f6c504630ecfa38c1516123019bdf67b921f1107.tar.gz | |
Allow user to define the time interval for "task is running" message
| -rw-r--r-- | include/core.h | 1 | ||||
| -rw-r--r-- | src/delivery_test.c | 3 | ||||
| -rw-r--r-- | src/globals.c | 1 | ||||
| -rw-r--r-- | src/stasis_main.c | 13 | 
4 files changed, 18 insertions, 0 deletions
| diff --git a/include/core.h b/include/core.h index 5011dea..ae0e8fe 100644 --- a/include/core.h +++ b/include/core.h @@ -65,6 +65,7 @@ struct STASIS_GLOBAL {      bool enable_rewrite_spec_stage_2; //!< Enable automatic @STR@ replacement in output files      long cpu_limit;      long parallel_fail_fast; +    int pool_status_interval; //!< Report "Task is running" every n seconds      struct StrList *conda_packages; //!< Conda packages to install after initial activation      struct StrList *pip_packages; //!< Pip packages to install after initial activation      char *tmpdir; //!< Path to temporary storage directory diff --git a/src/delivery_test.c b/src/delivery_test.c index 3809768..d79e088 100644 --- a/src/delivery_test.c +++ b/src/delivery_test.c @@ -25,18 +25,21 @@ void delivery_tests_run(struct Delivery *ctx) {              perror("mp_pool_init/parallel");              exit(1);          } +        pool[PARALLEL]->status_interval = globals.pool_status_interval;          pool[SERIAL] = mp_pool_init("serial", ctx->storage.tmpdir);          if (!pool[SERIAL]) {              perror("mp_pool_init/serial");              exit(1);          } +        pool[SERIAL]->status_interval = globals.pool_status_interval;          pool[SETUP] = mp_pool_init("setup", ctx->storage.tmpdir);          if (!pool[SETUP]) {              perror("mp_pool_init/setup");              exit(1);          } +        pool[SETUP]->status_interval = globals.pool_status_interval;          // Test block scripts shall exit non-zero on error.          // This will fail a test block immediately if "string" is not found in file.txt: diff --git a/src/globals.c b/src/globals.c index 667809b..b93566a 100644 --- a/src/globals.c +++ b/src/globals.c @@ -39,6 +39,7 @@ struct STASIS_GLOBAL globals = {          .enable_testing = true, ///< Toggle [test] block "script" execution. "script_setup" always executes.          .enable_rewrite_spec_stage_2 = true, ///< Leave template stings in output files          .parallel_fail_fast = false, ///< Kill ALL multiprocessing tasks immediately on error +        .pool_status_interval = 30, ///< Report "Task is running"  };  void globals_free() { diff --git a/src/stasis_main.c b/src/stasis_main.c index da050f2..8f14e5f 100644 --- a/src/stasis_main.c +++ b/src/stasis_main.c @@ -13,12 +13,14 @@  #define OPT_OVERWRITE 1005  #define OPT_NO_REWRITE_SPEC_STAGE_2 1006  #define OPT_PARALLEL_FAIL_FAST 1007 +#define OPT_POOL_STATUS_INTERVAL 1009  static struct option long_options[] = {          {"help", no_argument, 0, 'h'},          {"version", no_argument, 0, 'V'},          {"continue-on-error", no_argument, 0, 'C'},          {"config", required_argument, 0, 'c'},          {"cpu-limit", required_argument, 0, 'l'}, +        {"pool-status-interval", required_argument, 0, OPT_POOL_STATUS_INTERVAL},          {"python", required_argument, 0, 'p'},          {"verbose", no_argument, 0, 'v'},          {"unbuffered", no_argument, 0, 'U'}, @@ -39,6 +41,7 @@ const char *long_options_help[] = {          "Allow tests to fail",          "Read configuration file",          "Number of processes to spawn concurrently (default: cpus - 1)", +        "Report task status every n seconds (default: 30)",          "Override version of Python in configuration",          "Increase output verbosity",          "Disable line buffering", @@ -262,6 +265,16 @@ int main(int argc, char *argv[]) {              case OPT_PARALLEL_FAIL_FAST:                  globals.parallel_fail_fast = true;                  break; +            case OPT_POOL_STATUS_INTERVAL: +                globals.pool_status_interval = (int) strtol(optarg, NULL, 10); +                if (globals.pool_status_interval < 1) { +                    globals.pool_status_interval = 1; +                } else if (globals.pool_status_interval > 60 * 10) { +                    // Possible poor choice alert +                    fprintf(stderr, "Caution: Excessive pausing between status updates may cause third-party CI/CD" +                                    " jobs to fail if the stdout/stderr streams are idle for too long!\n"); +                } +                break;              case 'U':                  setenv("PYTHONUNBUFFERED", "1", 1);                  fflush(stdout); | 
