class WorkerThread(threading.Thread):
someList = []
__init__(self, someVariable):
self.someVariable = someVariable
__start__(self, queue):
while True:
id = queue.get()
self.doWork(id)
queue.task_done()
doWork(self, id):
result = do_some_slow_operation(id)
lock = Thread.Lock()
with lock:
self.someList.append(result)
I have a very basic scope question. In the above example, via trial and error, it seems all threads have scope to someList. But self.someVariable's scope is limited to each thread. Can someone confirm this is correct, or if someList should have an explicit additional keyword or annotation identifier to indicate it is a synchronized class variable?