lattonedi scritta con box.png
STMBOL 50 ANNI.png
Per vedere come funziona, vai al tuo sito pubblicato.
  • Tutti i post
  • I miei post
andersonjones850
06 giu 2018

Wisdom about python threads?

in The Success Forum

Hello,


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.


Please help.


I didn't find the right solution from the Internet.


References:-

https://www.derivative.ca/forum/viewtopic.php?t=11395&p=44185

IT Security animated Video


Thanks

0 commenti
0
0 commenti
  • Black Facebook Icon
  • Black YouTube Icon

IN CONTACT WITH US
 

T: +39 031 791 377

E:   info@lattonedil.it

PRIVACY