M
Modular10mo ago
Logan

Python print statements don't seem to do anything when deployed to server

from python import Python

fn main() raises:
try:
Python.add_to_path("./")
let bot = Python.import_module("main")
print("Starting Bot with Mojo")
_ = bot.main()
except e:
print("Error in main: ", e)
from python import Python

fn main() raises:
try:
Python.add_to_path("./")
let bot = Python.import_module("main")
print("Starting Bot with Mojo")
_ = bot.main()
except e:
print("Error in main: ", e)
In this code, when I deploy to railway it runs in a docker container. The issue is that "Starting Bot with Mojo" will print, but nothing I print inside the main function, which is python will work. Any idea why this could be? Is the docker container suppressing output somehow? Whenever I run locally, everything prints fine
1 Reply
Logan
Logan10mo ago
And in vanilla Python, I had to run my code from the dockerfile using Python -u main.py so it would run in unbuffered mode. In mojo all I seem to have is mojo main.mojo which leads to Python not having the -u flag I fixed it, for anyone else with a similar issue, all I had to do is set ENV PYTHONUNBUFFERED=1 in my dockerfile
Want results from more Discord servers?
Add your server