I was wondering if there was a better way to deal with locks while importing other modules. Right now I've got this...
import ot1, ot2, ot3
class Thread(threading.Thread):
def __init___(blah, blah):
def run(self):
data, my_lock = self.data, self.my_lock
return ot1.dostuff(data, my_lock) + ot2.dostuff(data, my_lock) + ot3.dostuff(data, my_lock)
if __name__ == '__main__':
my_lock = threading.Lock()
for x in range(10):
Thread(data, my_lock)
Because I'm importing things I have to pass the lock into the new areas, is there any way to work around this, like globally declare the lock. It would make my code a whole lot cleaner.
dostufffunctions access multiple data members from your thread class (dataandmy_lock). Would it make sense for them to be methods on the class itself?