Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Threading
#2
Why do you need threading? If you can locate the T in less than 30ms and if you don't need millisecond accuracy on the Arduino notification and if the Arduino comms are quick then this is superfluous

Threading is complicated when your threads write to the same variables. But here you would have one thread that periodically extracts the 'T' position and makes a tuples out of it, and a second thread that runs every 30ms, gets the tuple, and sends it to the Arduino. Not that using a tuple here is already a thread-aware tecnique, if you were using three different variables for X,Y,A, the Arduino thread could be reading them exactly when the video analysis thread updates them and obtain X,Y from the previous extract and A from the new extract. Using a tuple(*) ensures that all three values aere collected together.

(*) and not a list... the tuple contents are immutable...
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
Python Threading - by Amro_Al - Oct-30-2016, 09:55 AM
RE: Python Threading - by Ofnuts - Oct-30-2016, 10:48 AM
RE: Python Threading - by Amro_Al - Oct-30-2016, 12:50 PM
RE: Python Threading - by Ofnuts - Oct-30-2016, 03:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Concurrent futures threading running at same speed as non-threading billykid999 13 2,132 May-03-2023, 08:22 AM
Last Post: billykid999
  Tutorials on sockets, threading and multi-threading? muzikman 2 2,215 Oct-01-2021, 08:32 PM
Last Post: muzikman
  Can I open\use threading in Python? korenron 2 1,882 Jun-30-2021, 10:42 AM
Last Post: korenron
  Embedding python cause crash when use boost::asio multi threading udvatt108 0 1,782 Oct-04-2020, 03:15 PM
Last Post: udvatt108
  Python - Keyboard module - Threading problem ppel123 1 3,171 Apr-13-2020, 04:49 PM
Last Post: deanhystad
  Help Threading python robot lucandmendes 0 11,525 May-03-2018, 02:42 PM
Last Post: lucandmendes
  Problem with Python, MySQL and Multi-threading queries zagk 1 12,015 Jul-01-2017, 12:15 AM
Last Post: zagk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020