[Python-ideas] Simpler thread synchronization using "Sticky Condition"

Richard Whitehead richard.whitehead at ieee.org
Wed Mar 27 05:39:26 EDT 2019


Ben,

Thanks very much for your reply. Everything you say is true, and the system can certainly be made to work (and without the performance problem I described) using only Condition variables.

I think the correct version of my pseudo-code becomes:

def sender():
     while alive():
          wait_for_my_data_from_hardware()
           with condition:
                send_data_to_receiver()  # I think this has to be done inside the lock on the Condition
                condition.raise()

def receiver():
     while alive():
         while data available:
                 receive_all_data_from_sender()
                 process_data()
         with condition:  # only sleep when we have nothing to do
                 condition.wait()






More information about the Python-ideas mailing list