Python continues after CTRL-C - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python continues after CTRL-C (/thread-34518.html) |
Python continues after CTRL-C - kjbolhuis - Aug-06-2021 I have a programm running continious controlling the heatpump, fan and air-inlet to control the climate. This programm runs for more than a year now, but twice there the programm stopped running without an error. After a CTRL-C it proceeds. I found the code stopped in the included part of te code. def read_weergegevens(_orig_sens_buiten, _orig_sens_max_buiten, _orig_sens_min_buiten, _orig_sens_rv_buiten,_orig_sens_i_buiten ): try: _var_response = requests.get("https://www.weerstationtzandt.nl/realtime.txt") _var_weer = csv.reader(_var_response.text.strip().split('\n'),delimiter =' ') for _var_weergegevens in _var_weer: _sens_buiten = float(_var_weergegevens[2]) _sens_max_buiten = float(_var_weergegevens[26]) _sens_min_buiten = float(_var_weergegevens[28]) _sens_rv_buiten = float(_var_weergegevens[3]) _sens_press_buiten = float(_var_weergegevens[10]) _sens_i_buiten = _calc_enthalpy(_sens_buiten,_sens_rv_buiten,_sens_press_buiten/10) return _sens_buiten, _sens_max_buiten, _sens_min_buiten, _sens_rv_buiten , _sens_i_buiten except: return _orig_sens_buiten, _orig_sens_max_buiten, _orig_sens_min_buiten, _orig_sens_rv_buiten , _orig_sens_i_buitenThis piece of programm reads a frequently updated online file from nearby weatherstation and collects data from it. What can cause this behaviour and how can i prevent it. RE: Python continues after CTRL-C - deanhystad - Aug-06-2021 From the documentation of the Requests package. Quote:TimeoutsThe program did not stop running, it was waiting for the get() to complete. The requests.get must be catching the ctrl+c KeyboardInterrupt exception and exiting the function call. RE: Python continues after CTRL-C - kjbolhuis - Aug-06-2021 Thanks for your answer. This must be the solution. I've modified the programm. |