pinkuf.blogg.se

Python subprocess start background process
Python subprocess start background process








The class BackgroundTasks comes directly from starlette.background.

python subprocess start background process

If there was a query in the request, it will be written to the log in a background task.Īnd then another background task generated at the path operation function will write a message using the email path parameter. In this example, the messages will be written to the log.txt file after the response is sent. From fastapi import BackgroundTasks, FastAPI app = FastAPI () def write_notification ( email : str, message = "" ): with open ( "log.txt", mode = "w" ) as email_file : content = f "notification for










Python subprocess start background process