I've started using a technique for long operations in python and I'd like to know if it seems reasonable in a TD context, or if there are better or more standard ways of doing things.For this application, I have to communicate with three HTTP APIs (including sending files) and use a number of command line programs (a slew of small utilities to control a Fastec camera, and ffmpeg to assemble the camera's output frames into an h264 video file). My general approach so far has been to kick off work in a threading.Thread, then use a Timer CHOP to poll for a result. I use a threading.Lock for memory safety.For the HTTP stuff, this seems to work fine. The use case is pretty simple -- make a sequence of requests in python, and at the end, make sure things turn out OK. I'm using the requests module and write "synchronous" code that then wrapped in a thread.I'm doing something similar with the command-line tools, but I use the subprocess module. The ffmpeg code should be very similar to the http/requests code. The camera controls are a bit more complex, so I'm using a queue.Queue (which is conveniently synchronized) to pass command and response objects. A Timer CHOP calls a poll method that pops things off the queue and reacts accordingly.
I didn't find the right solution from the Internet.