Index: dialin/protocols/CAN.py =================================================================== diff -u -r36d927b9a28017a71935fd76a3249466d9a576b5 -r8ab23ed705264e4cdc7e43689d01f9c243ed612b --- dialin/protocols/CAN.py (.../CAN.py) (revision 36d927b9a28017a71935fd76a3249466d9a576b5) +++ dialin/protocols/CAN.py (.../CAN.py) (revision 8ab23ed705264e4cdc7e43689d01f9c243ed612b) @@ -464,7 +464,8 @@ @return: DialityCanMessenger object """ - + self.message_queue_mutex = threading.Lock() + self.response_dictionary_mutex = threading.Lock() self.logger = logger self.log_can = log_can self.message_queue = deque() @@ -647,6 +648,7 @@ # If it is not, this is a publication message and we need to call it's register function else: + self.message_queue_mutex.acquire() if DenaliCanMessenger.is_ui_received_channel(dialin_ch_id): # check if the channel is in ui channels if self.ui_received_function_ptr is not None: self.thread_pool_executor.submit( @@ -659,8 +661,8 @@ for function_id in self.sync_response_dictionary[dialin_ch_id][dialin_msg_id]: self.thread_pool_executor.submit( self.sync_response_dictionary[dialin_ch_id][dialin_msg_id][function_id], - complete_dialin_message - ) + complete_dialin_message) + self.message_queue_mutex.release() else: self.logger.critical("Invalid message: {}\n".format(self.messages)) @@ -697,6 +699,7 @@ # function_id is a UID for each callback per channel,msg pair. function_id = id(function) # if the channel_id exist, we update the dictionary for the channel_id + self.response_dictionary_mutex.acquire() if channel_id in self.sync_response_dictionary.keys(): if message_id in self.sync_response_dictionary[channel_id].keys(): self.sync_response_dictionary[channel_id][message_id].update({function_id: function}) @@ -706,6 +709,7 @@ # otherwise, we need to create the dictionary for the channel_id, msg_id pair else: self.sync_response_dictionary[channel_id] = {message_id: {function_id: function}} + self.response_dictionary_mutex.release() def register_received_all_ui_publication_function(self, function_ptr: Callable): """