I've got a problem with bottle, the _initialize
function is run twice. Example app:
@route("/index")
def index():
return "bang"
def _initialize():
print("bam")
if __name__ == "__main__":
_initialize()
run(reloader=True, host="localhost", port = 8990)
The output is:
bam
bam
Bottle v0.11.rc1 server starting up (using WSGIRefServer())...
Listening on http://localhost:8080/
Hit Ctrl-C to quit.
Why is it happening and how can I do such pre init in bottle?
The problem is the reloader=True
argument for the run
function. See http://bottlepy.org/docs/dev/tutorial.html#auto-reloading for the sentence:
All module-level code is executed at least twice! Be careful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With