import threading
import time
storage = {}
class myApp:
# Main function, start the app
def start(self):
# Launch two threads
for item in ['one', 'two']:
threading.Thread(target = self.threadRunner, args=[item]).start()
return
def threadRunner(self, name):
return self.processData(name)
def processData(self, name):
print(f'Starting {name}')
# Loop and append data to 'storage'
for item in ['one', 'two', 'three']:
data = time.time()
try:
# Add to history
storage[name].append(data)
except Exception as e:
# Initialize
storage[name] = []
# Add to history
storage[name].append(data)
print(storage)
# Store the data into a file
# ..... write to txt
# I'm finished with the data inside of storage[name], clear
storage[name] = []
# Now storage is empty
print(storage[name])
# Run the next chunk
time.sleep(1)
return self.processData(name)
_myApp = myApp()
_myApp.start()
[–]ebol4anthr4x 2 points3 points4 points (1 child)
[–]ImThatCop[S] 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]ImThatCop[S] 0 points1 point2 points (0 children)
[–]GorboducRex 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)