Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Ensure remaining application events are processed before exiting #7300

Merged
merged 1 commit into from Oct 24, 2023

Conversation

jcfr
Copy link
Member

@jcfr jcfr commented Oct 23, 2023

This update ensures that any pending messages logged from Python scripts are properly reported and written to log files before the application exits.

This issue was uncovered while working on #7299

To illustrate:

Before

  • With explicit call to slicer.app.processEvents():

    rm /tmp/Slicer-jcfr/*.log && \
    ./Slicer --python-code "import logging; logging.debug('EXPECTED DEBUG OUTPUT'); slicer.app.processEvents()" \
      --exit-after-startup 2>&1 > /dev/null && \
      (echo "Slicer exited without error" && cat $(ls -1 /tmp/Slicer-jcfr/*.log) | grep "EXPECTED DEBUG OUTPUT")
    
    [DEBUG][Python] 23.10.2023 17:35:16 [Python] (<string>:1) - EXPECTED DEBUG OUTPUT
    
  • Without explicit call to slicer.app.processEvents():

    rm /tmp/Slicer-jcfr/*.log && \
    ./Slicer --python-code "import logging; logging.debug('EXPECTED DEBUG OUTPUT');" \
      --exit-after-startup 2>&1 > /dev/null && \
      (echo "Slicer exited without error" && cat $(ls -1 /tmp/Slicer-jcfr/*.log) | grep "EXPECTED DEBUG OUTPUT")
    

Message with EXPECTED DEBUG OUTPUT is missing from the log file

After

  • With explicit call to slicer.app.processEvents():

    rm /tmp/Slicer-jcfr/*.log && \
    ./Slicer --python-code "import logging; logging.debug('EXPECTED DEBUG OUTPUT'); slicer.app.processEvents()" \
      --exit-after-startup 2>&1 > /dev/null && \
      (echo "Slicer exited without error" && cat $(ls -1 /tmp/Slicer-jcfr/*.log) | grep "EXPECTED DEBUG OUTPUT")
    
    [DEBUG][Python] 23.10.2023 17:39:25 [Python] (<string>:1) - EXPECTED DEBUG OUTPUT
    
  • Without explicit call to slicer.app.processEvents():

    rm /tmp/Slicer-jcfr/*.log && \
    ./Slicer --python-code "import logging; logging.debug('EXPECTED DEBUG OUTPUT');" \
      --exit-after-startup 2>&1 > /dev/null && \
      (echo "Slicer exited without error" && cat $(ls -1 /tmp/Slicer-jcfr/*.log) | grep "EXPECTED DEBUG OUTPUT")
    
    [DEBUG][Python] 23.10.2023 17:38:59 [Python] (<string>:1) - EXPECTED DEBUG OUTPUT
    

This update ensures that any pending messages logged from Python
scripts are properly reported and written to log files before the
application exits.
@jcfr jcfr merged commit 9e58150 into Slicer:main Oct 24, 2023
8 checks passed
@jcfr jcfr deleted the ensure-app-events-processed-before-exit branch October 24, 2023 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants