bottle: won't start with pythonw
I wrote a simple service, and tried to deploy it on windows. I used pythonw.exe to start the script. But bottle won’t start. The process started and then quickly closed. But if I started it using python.exe, the process works fine. I think this might be a bug. The process won’t start even if I just imported bottle but not doing anything. The code looks like this. pythonw hello_world.py would start, and then quickly shutdown.
'''
hello_world.py
'''
import bottle
import time
if __name__ == '__main__':
while True:
print('Hello, world')
time.sleep(2)
However, python hello_world.py will do the work, and if I comment import bottle out, pythonw will do the job too.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (3 by maintainers)
Running a server on windows is a pretty common use case for pythonw.exe (the other is GUI apps). So there is good reason to run a bottle application without a console.
You can add:
to your app before you import bottle.
For some reason, nothing that gets written to stdout/stderr actually shows up in the files once bottle is imported, but aside from that it seems to work.
@seth-c-stenzel For it to work, you have to do it in this order:
Can you confirm it works for you?