osmcode / pyosmium

Python bindings for libosmium
https://osmcode.org/pyosmium
BSD 2-Clause "Simplified" License
314 stars 64 forks source link

Python program not terminating properly #247

Closed kubatjak closed 4 months ago

kubatjak commented 4 months ago

Discussed in https://github.com/osmcode/pyosmium/discussions/233

Originally posted by **kubatjak** September 8, 2023 Hello, I have been running a very simple python script using the SimpleHandler. The program runs correctly till the end but then it fails to terminate properly. The program cannot be killed by keyboard interupt. It happens in Windows command line and PowerShell and GitBash consoles. It happens only after using apply_file, just having an instance of Handler does not cause any issues. Here's the script: ```python import osmium import atexit class Handler(osmium.SimpleHandler): def __init__(self) -> None: super().__init__() self.num_nodes = 0 def node(self, n): self.num_nodes += 1 def cleanup(): print('Cleanup called') print('Trying to terminate the program ...') def main(): osm_file = r'map_14.4086_50.0726_14.4195_50.0761.osm' handler = Handler() handler.apply_file(osm_file) print('# nodes:', handler.num_nodes) if __name__ == '__main__': atexit.register(cleanup) try: main() except Exception as e: print(e) ``` Would someone know what could be the cause of the problem? Thank you!
kubatjak commented 4 months ago

It seems it's enough to have it in Discussions even though people somehow hesitate to confirm this and prefer boosting their egos by posting long comments about how your issue is poorly documented instead of directly answering your question. Closing this.