Change request #1076

Remove @GApplicationPars.write@ call from GApplication() destructor?

Added by Deil Christoph over 10 years ago. Updated about 10 years ago.

Status:In ProgressStart date:01/13/2014
Priority:NormalDue date:
Assigned To:Deil Christoph% Done:

0%

Category:-
Target version:-
Duration:

Description

Trying to I just ran into this behaviour of a default GApplication while testing something on the Python command line:

ChristophMacbook-2:my_tests deil$ cat test_GApplication_exit.cpp 
#include <iostream>
#include "GammaLib.hpp" 

int main(void) {
  GApplication a;
}
ChristophMacbook-2:my_tests deil$ ./test_GApplication_exit 
libc++abi.dylib: terminating with uncaught exception of type GException::par_file_open_error: *** ERROR in GApplicationPars::write(std::string&): Unable to open parameter file "/Users/deil/pfiles/".
Abort trap: 6
ChristophMacbook-2:my_tests deil$ ipython -c 'import gammalib; app = gammalib.GApplication()'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 3132, in atexit_operations
    self.reset(new_session=False)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 1182, in reset
    for k in drop_keys:
RuntimeError: *** ERROR in GApplicationPars::write(std::string&): Unable to open parameter file "/Users/deil/pfiles/".
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 3132, in atexit_operations
    self.reset(new_session=False)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 1182, in reset
    for k in drop_keys:
RuntimeError: *** ERROR in GApplicationPars::write(std::string&): Unable to open parameter file "/Users/deil/pfiles/".

Can / should this behaviour be improved, e.g. by removing the GApplicationPars::write call in the GApplications destructor?
I think in general destructors are not supposed to acquire resources or throw and it would be OK to leave this call to write to the user of GApplication?


Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen about 10 years ago

  • Priority changed from Low to Normal

Probably this should indeed be done. The actual logic writes the parfile only at the end, which means that parameters are not updated in case that the program crashes. This is not very convenient. Fermi/LAT Science Tools write parameters immediately after a query, and this could also be done here. This would increase the writes, but at the same time, would enhance the user experience.

#2 Updated by Knödlseder Jürgen about 10 years ago

  • Status changed from Feedback to In Progress

Not sure why this has status “Feedback”. It still needs an implementation.

The logic should be that the parfile is always written after changing a parameter, not waiting for an application to terminate. Otherwise, parfiles will not get updated when the application fails.

Also available in: Atom PDF