multithreading - Python and threading: Why does "large" list entity get lost when accessing from other method? -
a large entity (list) created in 1 method (foo
) , bound self.result
. attempt access entity in second method (transmit
) fails starting @ size (something between 150,000 , 155,000 characters in list). printing (print self.result)
inside transmit
leaves me none. guess important: self.foo
directly called in separate thread.
please help. how such "large" entity separate thread main thread without such limitation?
... def apply(self): self.get_data() self.start_foo_thread() def start_foo_thread(self): self.foo_thread = threading.thread(target=self.foo) self.foo_thread.daemon = true self.progressbar.start() self.foo_thread.start() self.master.after(20, self.check_foo_thread) def check_foo_thread(self): if self.foo_thread.is_alive(): self.master.after(20, self.check_foo_thread) else: self.progressbar.stop() def foo(self): s = self.stringinput n = self.numberinput list = multiply_str_into_list(s, n) self.result = list_to_text(list) print self.result # output not none def transmit(self): print self.result # output none more 155,000 characters in list return self.result def multiply_str_into_list(string, n): #takes string , multiplies n , writes list n_string = [] in range(0,n): n_string.append(string) return n_string def list_to_text(list): #takes list input , joins str each list item on new line = '\n'.join(list) return
you don't provide enough information reproduce problem, let alone debug it, guess @ point, doing this:
self.result = self.result.append(x)
since .append()
modifies list in place, , returns none
, clobber reference list. needn't .append()
either -- of methods mutate lists return none
.
as why happening @ size, perhaps have code above triggered @ size, or else red herring.
Comments
Post a Comment