-1

Please tell me if there is a better way to do this in python.

I have an endpoint in the flask app that takes in the request, validate, and starts a thread and returns a response saying request if valid and a process is started. At the end of the thread, I will send a request to the call back URL saying the threading process has completed.

  1. is there a way to do this without threading?
  2. what are the other options to do an asynchronous endpoint call in python where the client doesn't till the process is complete.
cerofrais
  • 1,117
  • 1
  • 12
  • 32

1 Answers1

0
  1. You can try using features from Python 3.4+'s asyncio. This will change the working of the program to cooperative multitasking, so need to be a bit careful. Some answers on how to do that here.

  2. Maybe websockets would work for you. The Starlette framework is async-first and has inbuilt websocket support.

max
  • 4,248
  • 2
  • 25
  • 38