I have this simple Flask application:
from flask import Flask
import prolog_handler as p
app = Flask(__name__)
app.debug = False
@app.route('/')
def hello():
for rule in p.rules:
print rule
return 'hello'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080)
The prolog_handler module starts a session with a tripost and loads some rules. It also has an atexit function that terminates the session and prints a message like "Close ...". I start the server from a bash prompt with python myapp.py. Whenever I press CTRL-C to stop the server, nothing happens. I do not go back to the bash prompt, and I do not see the message "Closing ...". I also tried to do this using Web.py with the same results.
What prolog_handler does is literally as simple as this:
tstore = openPrologSession()
rules = ...
def cleanUp():
print "Closing..."
tstore.endSession()
atexit.register(cleanUp)
So why is it so hard to just complete the atexit task?
PS: , Prolog , , "...", "...", CTRL-C, bash. , . atexit, ?