You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realized that using the embedded invocation of uvicorn via serve() from the top process causes the primary code to execute twice (from within the same process).
This was mostly harmless (duplicated log records in an activity table) but undesired in my instance. It is unrelated to running multiple parallel server instances.
When run under uvicorn with "uvicorn --port 5001 fasthtml_test:app" the main logic only executes once.
I first observed in more complex logic, but saw the behavior in your simple example as well. Here is snippet of initial sample modified to show this behavior with print()...
from fasthtml.common import FastHTML, serve
import os
Working with FastHTML and loving it so far.
I realized that using the embedded invocation of uvicorn via serve() from the top process causes the primary code to execute twice (from within the same process).
This was mostly harmless (duplicated log records in an activity table) but undesired in my instance. It is unrelated to running multiple parallel server instances.
When run under uvicorn with "uvicorn --port 5001 fasthtml_test:app" the main logic only executes once.
I first observed in more complex logic, but saw the behavior in your simple example as well. Here is snippet of initial sample modified to show this behavior with print()...
from fasthtml.common import FastHTML, serve
import os
app = FastHTML()
print(f'fasthtml_test loaded os_getpid={os.getpid()}')
@app.get("/")
def home():
return "
Hello, World
"serve()
The text was updated successfully, but these errors were encountered: