|
[Sponsors] |
April 25, 2014, 12:23 |
PyFoam killing my SSH sessions
|
#1 |
Member
Vincent Leroy
Join Date: Jul 2012
Location: Rhode-Saint-Genèse, Belgium
Posts: 43
Rep Power: 14 |
Dear Foamers,
I recently decided to switch to PyFoam to run and monitor my cases. However, I encountered an annoying issue: some PyFoam functions seem to kill my SSH sessions. Here's the kind of output I get: Code:
<some output> patch 0 (start: 19800 size: 50) name: inlet patch 1 (start: 19850 size: 50) name: outlet patch 2 (start: 19900 size: 50) name: lowerWall patch 3 (start: 19950 size: 50) name: upperWall patch 4 (start: 20000 size: 200) name: cylinderWalls patch 5 (start: 20200 size: 10000) name: back patch 6 (start: 30200 size: 10000) name: front End Killing PID 29668 Connection to hpc4 closed by remote host. Connection to hpc4 closed. |
|
April 25, 2014, 12:51 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings Vincent,
That's a curious occurrence. A few questions:
Bruno
__________________
|
|
April 25, 2014, 16:27 |
|
#3 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
I've never seen that kind of behaviour and can only guess (although most guesses say "it's not my (PyFoam) fault but a weird thing where the termination signal of the thread that runs the OF-command". But that is a REALLY wild guess)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
April 27, 2014, 07:07 |
|
#4 | |
Member
Vincent Leroy
Join Date: Jul 2012
Location: Rhode-Saint-Genèse, Belgium
Posts: 43
Rep Power: 14 |
Quote:
Thank you for answering so quickly. Here are the answers to your questions:
Allrun.py Code:
#!/usr/bin/python # Run script # Requires pyFoam import os, subprocess, configobj from PyFoam.Applications.ClearCase import ClearCase from PyFoam.Applications.Runner import Runner from PyFoam.Applications.FromTemplate import FromTemplate def touch(path): with open(path, 'a'): os.utime(path, None) def main(): """ Steps for the run: - Cleanup the case (remove time directories) - Build the mesh - Run the createPatch tool - Run the mapFields utility (import average fields) - Run the decomposePar tool - Run the application - Run the postprocessing programs (reconstructPar, sample, foamCalc and foamCalcEx) - Generate the .foam files for visualization with ParaView """ nProc = 2 rootPath = os.getcwd() # Load case parameters CaseParameters = configobj.ConfigObj("CaseParameters.ini") # Cleanup ClearCase() # Build dictionaries os.chdir(os.path.join(rootPath, "constant/polyMesh/")) subprocess.call(["python", "blockMeshDict.py"]) os.chdir(rootPath) os.chdir(os.path.join(rootPath, "system/")) subprocess.call(["python", "createPatchDict.py"]) os.chdir(rootPath) for dictName in CaseParameters['Dictionaries']: FromTemplate(args=[ dictName, CaseParameters['Dictionaries'][dictName] ]) # Move resulting files in 0/templates to their runtime location os.rename("0/templates/TTilde", "0/TTilde") # Build mesh Runner(args=["blockMesh"]) # Run the createPatch utility Runner(args=["createPatch", "-overwrite"]) # Map input average fields Runner(args=[ "mapFields", "input/average" ]) # Map input velocity deviations Runner(args=[ "mapFields", "-consistent", "input/cell" ]) # Decompose Runner(args=[ "decomposePar", "-force" ]) # Run application Runner(args=[ "--proc=%d"%nProc, "thermoDownscalingFoam", ]) # Reconstruct if necessary Runner(args=["reconstructPar"]) # Create visualization files if necessary touch("case.foam") if __name__ == "__main__": main() |
||
April 27, 2014, 07:13 |
|
#5 | |
Member
Vincent Leroy
Join Date: Jul 2012
Location: Rhode-Saint-Genèse, Belgium
Posts: 43
Rep Power: 14 |
Quote:
Thank you for your answer. In the example output I posted, the killing happens right at the end of the execution of the blockMesh utility using a Runner object (see the Allrun.py script posted above). The script should then proceed with the execution of various utilities and a solver. Vincent |
||
April 27, 2014, 20:11 |
|
#6 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
April 28, 2014, 15:38 |
|
#7 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
Quote:
I'm not familiar enough with Python to know this, but when using bash scripts, it's possible to use the "-e" set option: Code:
set -e Code:
set +e Best regards, Bruno
__________________
|
||
April 29, 2014, 06:35 |
|
#8 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
One thing: it seems that the output from PyFoam messes up some terminals. What you could try is to add the "--silent"-option to the Runner calls. This will print nothing to the terminal but you should still have the log-files (don't use "--progress" because it tends to make this worse: some terminals have problem with '\r') Other option is to go to PyFoam.Execution.BasicRunner.py and add print-statemtents before self.run.interrupt() to find out how the interrupt got there (there should also be traces in ~/pyFoam/log/general and the PyFoamState.TheState in the case should read "Interrupted" if PyFoam thinks that someone Ctrl-C'ed it (but that is only diagnostic and I wouldn't know how to fix this)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
April 29, 2014, 06:52 |
|
#9 |
Member
Vincent Leroy
Join Date: Jul 2012
Location: Rhode-Saint-Genèse, Belgium
Posts: 43
Rep Power: 14 |
Thank you for your advice, gentlemen. I will try to do what Bernhard suggests ASAP and I'll come back if I make any progress.
Regards, Vincent |
|
May 5, 2014, 08:55 |
Update
|
#10 | |
Member
Vincent Leroy
Join Date: Jul 2012
Location: Rhode-Saint-Genèse, Belgium
Posts: 43
Rep Power: 14 |
Quote:
I suppressed the terminal output using the --silent option. Killings still occurred. I noticed that they seem to happend preferably at the end of the execution of utilities (all of them) and quite randomly. I tried to run the utilities using the UtilityRunner class and killings stopped occurring. However, I still get errors like: Code:
Getting LinuxMem: [Errno 2] No such file or directory: '/proc/27467/status' |
||
May 5, 2014, 13:54 |
|
#11 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Anyway: If you're doing scripts PyFoam.Execution.UtilitiyRunner might be the better choice anyway (the PyFoam.Applications-classes are mainly for quickly "translating" what you did on the shell to a script)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
May 9, 2014, 11:44 |
Solution found
|
#12 | |
Member
Vincent Leroy
Join Date: Jul 2012
Location: Rhode-Saint-Genèse, Belgium
Posts: 43
Rep Power: 14 |
Quote:
|
||
July 2, 2014, 06:29 |
|
#13 | |
Member
Vincent Leroy
Join Date: Jul 2012
Location: Rhode-Saint-Genèse, Belgium
Posts: 43
Rep Power: 14 |
Quote:
I have been working on the problem again. I still get the getLinuxMem errors I mentioned. After testing on several configurations, it seems to be happening more frequently on my production configuration than on my dev computer. There are major differences between them, but the most important one is that the production computer has much faster processors than the development one. This also happens only on very 'small' cases. When processing big amounts of data, I do not see these messages. So my hypothesis would be: maybe this is just a matter of execution speed. Maybe the process started using any Runner class terminates so quickly that when any function using its PID is run, it cannot do its work as expected. What do you think about that? |
||
July 2, 2014, 13:37 |
I guess I was right
|
#14 |
Member
Vincent Leroy
Join Date: Jul 2012
Location: Rhode-Saint-Genèse, Belgium
Posts: 43
Rep Power: 14 |
I added " && sleep N", where N is a number to be chosen for every task, to give PyFoam enough time to sort things out. So the typical call looks like
Code:
UtilityRunner( logname="PyFoamUtility.decomposePar", silent=not(verbose > 1), argv=[ "decomposePar", "-case", caseDirectory, "-force", " && sleep 1" ]).start() |
|
July 2, 2014, 19:35 |
|
#15 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
The problem (as you said) is timing: pyFoam puts the utility into another thread so that it can "look at it from outside". Problem is that sometimes the utility is finished before PyFoam can have a first look.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
July 3, 2014, 06:25 |
|
#16 | |
Member
Vincent Leroy
Join Date: Jul 2012
Location: Rhode-Saint-Genèse, Belgium
Posts: 43
Rep Power: 14 |
Quote:
|
||
Tags |
pyfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[PyFoam] unknown or ambiguous terminal type x11 | Tobi | OpenFOAM Community Contributions | 6 | August 13, 2020 12:09 |
[PyFoam] library import error | 00Sibbe | OpenFOAM Community Contributions | 5 | October 15, 2014 12:41 |
openfoam on 2 machines with passwordless ssh | devayabir | OpenFOAM | 10 | August 4, 2014 19:25 |
[PyFoam] How to extract values with pyFoam? | chriss85 | OpenFOAM Community Contributions | 13 | January 27, 2014 21:16 |
pyFoam, pyFlu, extend: How does they relate? | Horus | OpenFOAM | 9 | May 21, 2011 13:49 |