Op 26-10-16 om 12:22 schreef pozz:
> Il 26/10/2016 09:13, pozz ha scritto:
> > [...]
>> When the user press Start button (the pressed handler is in the GUI
>> class):
>>
>>   self.comm_active = True
>>   threading.Thread(target=self.comm_thread).start()
>>
>> The backend thread is:
>>
>>   def comm_thread(self):
>>     while self.comm_active:
>>       self.device.get_status()
>>       GLib.idle_add(self.polling_received)
>>       time.sleep(1)
>>     self.m.close()
> > [...]
>
> Now I have some concerns even in using self.comm_active.  It is a boolean 
> variable
> accessed by the GUI thread (inside Start/Stop buttons handler) and backend 
> thread
> (in the "while self.comm_active" instruction).

> Is it safe to access this variable from two different threads?
> Should I implement a safer and more complex mechanism?  If yes, what 
> mechanism?

Accessing from multiple thread shouldn't be a problem. As long as you only 
change
it in one thread.


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to