IBAMR / autoibamr

GNU Lesser General Public License v3.0
10 stars 3 forks source link

isAlive() removed from python >= 3.9 #77

Closed elbert5770 closed 2 years ago

elbert5770 commented 2 years ago

Error below with Python 3.10.4

Running Executable WITHOUT threads to time it out
Executing: /usr/bin/mpicc  -o /tmp/petsc-zwugv4xl/config.setCompilers/conftest    /tmp/petsc-zwugv4xl/config.setCompilers/conftest.o  -lpetsc-ufod4vtr9mqHvKIQiVAm
Possible ERROR while running linker: exit code 1
stderr:
/usr/bin/ld: cannot find -lpetsc-ufod4vtr9mqHvKIQiVAm: No such file or directory
collect2: error: ld returned 1 exit status
Running Executable WITHOUT threads to time it out
Executing: /usr/bin/mpicc -c -o /tmp/petsc-zwugv4xl/config.setCompilers/conftest.o -I/tmp/petsc-zwugv4xl/config.setCompilers   /tmp/petsc-zwugv4xl/config.setCompilers/conftest.c 
Successful compile:
Source:
#include "confdefs.h"
#include "conffix.h"

int main() {
;
  return 0;
}
Running Executable WITHOUT threads to time it out
Executing: /usr/bin/mpicc  -o /tmp/petsc-zwugv4xl/config.setCompilers/conftest    /tmp/petsc-zwugv4xl/config.setCompilers/conftest.o 
Testing executable /tmp/petsc-zwugv4xl/config.setCompilers/conftest to see if it can be run
Executing: /tmp/petsc-zwugv4xl/config.setCompilers/conftest
Running Executable with threads to time it out at 60
Executing: /tmp/petsc-zwugv4xl/config.setCompilers/conftest
*******************************************************************************
        CONFIGURATION CRASH  (Please send configure.log to petsc-maint@mcs.anl.gov)
*******************************************************************************
'InShell' object has no attribute 'isAlive'  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/configure.py", line 440, in petsc_configure
    framework.configure(out = sys.stdout)
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/config/framework.py", line 1229, in configure
    self.processChildren()
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/config/framework.py", line 1218, in processChildren
    self.serialEvaluation(self.childGraph)
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/config/framework.py", line 1193, in serialEvaluation
    child.configure()
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/config/setCompilers.py", line 1789, in configure
    self.executeTest(self.checkCCompiler)
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/config/base.py", line 139, in executeTest
    ret = test(*args,**kargs)
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/config/setCompilers.py", line 638, in checkCCompiler
    self.checkCompiler('C')
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/config/setCompilers.py", line 504, in checkCompiler
    if not self.checkRun(linkLanguage=linkLanguage):
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/config/base.py", line 681, in checkRun
    (output, returnCode) = self.outputRun(includes, body, cleanup, defaultArg, executor,linkLanguage=linkLanguage, timeout = timeout, threads = threads)
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/config/base.py", line 662, in outputRun
    (output, error, status) = Configure.executeShellCommand(command, log = self.log, timeout = timeout, threads = threads)
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/script.py", line 200, in executeShellCommand
    return Script.executeShellCommandSeq([command], checkCommand=checkCommand, timeout=timeout, log=log, lineLimit=lineLimit, cwd=cwd,logOutputflg = logOutputflg, threads = threads)
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/script.py", line 249, in executeShellCommandSeq
    (output, error, status) = runInShell(commandseq, log, cwd)
  File "/home/elbert5770/autoibamr/tmp/build/petsc-lite-3.13.1/config/BuildSystem/script.py", line 239, in runInShell
    if thread.isAlive():

Forum post that isAlive() removed in Python 3.9 https://github.com/fkie/multimaster_fkie/issues/149

Location in code that uses isAlive() /home/elbert5770/autoibamr/tmp/unpack/petsc-3.13.1/config/BuildSystem/script.py

def runInShell(commandseq, log, cwd):
      if not useThreads: log.write('UseThreads is off\n')
      if useThreads and threads:
        import threading
        log.write('Running Executable with threads to time it out at '+str(timeout)+'\n')
        class InShell(threading.Thread):
          def __init__(self):
            threading.Thread.__init__(self)
            self.name = 'Shell Command'
            self.setDaemon(1)
          def run(self):
            (self.output, self.error, self.status) = ('', '', -1) # So these fields exist even if command fails with no output
            (self.output, self.error, self.status) = Script.runShellCommandSeq(commandseq, log, cwd)
        thread = InShell()
        thread.start()
        thread.join(timeout)
        if thread.isAlive():
          error = 'Runaway process exceeded time limit of '+str(timeout)+'\n'
          log.write(error)
          return ('', error, -1)
        else:
          return (thread.output, thread.error, thread.status)
      else:
        log.write('Running Executable WITHOUT threads to time it out\n')
        return Script.runShellCommandSeq(commandseq, log, cwd)

    (output, error, status) = runInShell(commandseq, log, cwd)
    output = logOutput(log, output,logOutputflg)
    checkCommand(commandseq, status, output, error)
    return (output, error, status)
elbert5770 commented 2 years ago

FWIW, PETsc has updated their version of the script file to use is_alive().

def runInShell(commandseq, log, cwd, env):
      if useThreads and threads:
        import threading
        log.write('Running Executable with threads to time it out at '+str(timeout)+'\n')
        class InShell(threading.Thread):
          def __init__(self):
            threading.Thread.__init__(self)
            self.name = 'Shell Command'
            self.setDaemon(1)
          def run(self):
            (self.output, self.error, self.status) = ('', '', -1) # So these fields exist even if command fails with no output
            (self.output, self.error, self.status) = Script.runShellCommandSeq(commandseq, log, cwd, env)
        thread = InShell()
        thread.start()
        thread.join(timeout)
        if thread.is_alive():
          error = 'Runaway process exceeded time limit of '+str(timeout)+'\n'
          log.write(error)
          return ('', error, -1)
        else:
          return (thread.output, thread.error, thread.status)
      else:
        return Script.runShellCommandSeq(commandseq, log, cwd, env)

    (output, error, status) = runInShell(commandseq, log, cwd, env)
    output = logOutput(log, output,logOutputflg)
    checkCommand(commandseq, status, output, error)
    return (output, error, status)
drwells commented 2 years ago

Thanks for reporting this - I will patch this and a few other things in a week or so when we finalize the next ibamr release.