Mantid hangs on script exit

A number of scripts I have written seem to work, but not exit cleanly when run in the python window. These generally do some data manipulation before outputting ascii results tables.

Expected behavior

Files written, then script completes

Actual behavior

Files written, script does not complete (or takes a very long time after the output file is written and available).

Steps to reproduce the behavior

My most recent script with this issue is:
TimeSeries.py (3.4 KB)

Output path is on line 6, so you should change that to wherever suits you before running.

Platforms affected

Currently running 3.9.20170529.820 on windows 7, but has i have seen similar issues previously.

Ian,

Thanks for this and attaching a script that reproduces the problem nicely. I’m have a look into it at the moment.

The script window within Mantidplot does two things that are relatively expensive, and can cause hangs when handling tight loops:

  1. The current line arrow, showing the currently executing line, determining the currently executing line is surprisingly expensive.
  2. Printing out from tight loops, Mantid has to capture the output from Python and transfer the output across threads to display it in the Output Window.

This is not a perfect answer, but there are two things you can do to work around this problem.

  1. Remove the print you have in Line 81.
  2. Go to the Window menu and turn off Progress Reporting (This is the current line arrow).

When I did both of these it not only stopped any hangs the script ran much faster too.
If you like the progress arrow another way to prevent it trying to follow the nested for loops would be to move some of that code into another file that you import. Mantid will not attempt to track progress into imported file, so you would still have the overview from the high level functions of the script, and move the nested loops into another file.

Regards,
Nick

Thanks Nick,

that has sorted it out for me and it now runs nicely. I’ll keep the progress arrow off unless debugging!

Ian