Short-bus / pilomar

RaspberryPi based miniature observatory
https://shortbus.blog/
GNU General Public License v3.0
63 stars 14 forks source link

After building the Hipparcos star catalog, pilomar terminates at target prompt #39

Open Short-bus opened 7 months ago

Short-bus commented 7 months ago

If pilomar has to build the Hipparcos start catalog when first installed it sometimes fails when the first user input is requested. After successfully completing the catalog build it asks for a target to be selected, but the prompt fails with an IO error.

Restarting the program solves the problem.

The catalog build takes a long time and something with the user IO seems to timeout during that period.

Is it better to have a clean shutdown after building the catalog and asking the user to restart the program anyway?

Short-bus commented 7 months ago

Until the root cause is identified the program will terminate more cleanly after constructing the Hipparcos catalog.

Short-bus commented 7 months ago

Recreated the error condition

Menu option : Traceback (most recent call last): File "pilomar.py", line 6358, in Session.Target = TargetSelection() File "pilomar.py", line 6318, in TargetSelection option = TargetMenu.Prompt() # As the user to select an option from the menu. File "/home/pi/pilomar/src/textcolor.py", line 2547, in Prompt answer = input(textcolor.cyan('Menu option : ')) # Prompt for input. ValueError: I/O operation on closed file. pi@pilomar3b:~/pilomar/src $

Does the routine that reads the downloaded data close the terminal I/O somehow?

Short-bus commented 7 months ago

Code which performs the Hipparcos catalog build...

from skyfield.api import Loader # Create own 'load' functionality by specifying the download directory this way. ... load = Loader(ProjectRoot + '/data') # Create own version of Skyfield 'load' object. This version saves cache files in the data directory. ... with load.open(HipparcosUrl,reload=ReloadData) as f: # load function will use disc cache if it already exists. HipparcosDf = hipex_load_dataframe(f) # Hipparcos data as a Pandas dataframe. MainLog.Log('Hipparcos data:',list(HipparcosDf.columns),terminal=False) MainLog.Log("Saving Hipparcos cache as",HipparcosCacheFile,terminal=True) HipparcosDf.to_pickle(HipparcosCacheFile)

Simple experiment with the pandas.to_pickle() function did not cause any problems for follow-on input() statement.

Short-bus commented 6 months ago

Found this reference to a similar situation online... https://stackoverflow.com/questions/50751103/i-o-operation-on-closed-file-using-input

The discussion suggests that one possibility is an 'exit()' statement buried in some other library, this could close the sys.stdin files. The same error message appeared elsewhere in the program during testing, that may also be an exit() statement in an included procedure.

Short-bus commented 5 months ago

Have now seen the same error message occur at other prompts a couple of times, it appears to happen if the program is left unattended for a long time. Could it be related to the VNC connection?