View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0004470 | Slicer4 | Core: Scripting (Wrapping, Python) | public | 2017-10-30 15:39 | 2018-06-01 09:44 |
| Reporter | inorton | Assigned To | inorton | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | not fixable | ||
| Product Version | |||||
| Target Version | Fixed in Version | ||||
| Summary | 0004470: Python slicer.util.exit is asynchronous? | ||||
| Description | Calling slicer.util.exit multiple times within a Python invocation/script leads to surprising results: only the last call exit status is counted. This can be unhelpful when writing a Python test script that returns status via exit code. | ||||
| Steps To Reproduce | On unixy system: /path/to/Slicer/Slicer --python-code "slicer.util.exit(1); slicer.util.exit(0)" | ||||
| Tags | No tags attached. | ||||
|
Good catch. This function calls http://doc.qt.io/qt-4.8/qcoreapplication.html#exit This means we should stop interpreting python code after the user expect the application to exit/quit. Is it something you could look into ? |
|
|
For now I'm just using sys.exit directly from Python. This kills the application and gives the expected result. I can take a look at some point, although from the link the issue may be upstream. I confirmed the behavior is identical in Qt5. |
|
|
sys.exit should be avoided as it does not let the software to properly close resources, clean up state before exit. etc.. The current behavior is that the error code that was most recently set using slicer.util.exit() will be returned. I think this is a good choice and maybe it could be surprising for command-line tool developers but is expected for application developers. What do you think about resolving this issue by improving documentation? See this pull request: https://github.com/Slicer/Slicer/pull/964 |
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2017-10-30 15:39 | inorton | New Issue | |
| 2017-10-30 15:39 | inorton | Status | new => assigned |
| 2017-10-30 15:39 | inorton | Assigned To | => jcfr |
| 2017-10-30 15:46 | jcfr | Note Added: 0015366 | |
| 2017-10-30 16:14 | inorton | Note Added: 0015367 | |
| 2017-10-30 16:14 | inorton | Assigned To | jcfr => inorton |
| 2018-05-30 14:27 | lassoan | Note Added: 0015855 | |
| 2018-06-01 09:44 | inorton | Status | assigned => closed |
| 2018-06-01 09:44 | inorton | Resolution | open => not fixable |