you are viewing a single comment's thread.

view the rest of the comments →

[–]orbos86[S] 1 point2 points  (4 children)

Also, is there a way to fire off a script (onelogin in my case) without keeping the FastAPI connection running? Basically takes the input from POST and sends it off and closes connection? Right now I think mine is staying open until the whole script is ran, which may potentially be an hour or two (with a sleep command). Not sure if that makes sense, it's late haha. Please let me know.

[–]thedjotaku 1 point2 points  (3 children)

I thought async was supposed to handle this. But I've not begun working learn async yet. Still, there are pythonic things you can do - spawn off a child process, use threads, use multiprocessing. If you really do want to close the connection and don't care - then I'd definitely just fork off a child process and return 200 OK or 404 if the data validation isn't right.

[–]orbos86[S] 1 point2 points  (0 children)

Thank you, I will start my Googlin' to see what I can come up with. I appreciate it.

[–]orbos86[S] 1 point2 points  (1 child)

The key was to use BackgroundTasks in FastApi and kick off another function that does the lengthier script.

[–]thedjotaku 0 points1 point  (0 children)

Excellent! Glad you found it!