mirror of
https://github.com/dbarzin/pandora-box.git
synced 2025-07-19 13:29:42 +02:00
add threading
This commit is contained in:
parent
f1b9342f98
commit
c265840ca2
2 changed files with 755 additions and 642 deletions
864
pandora-box.py
864
pandora-box.py
File diff suppressed because it is too large
Load diff
|
@ -15,17 +15,16 @@ class myThread (threading.Thread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print(f"Thread-{self.id} Starting ")
|
print(f"Thread-{self.id} Starting ")
|
||||||
process_data(self.id, self.q)
|
self.process_data()
|
||||||
print(f"Thread-{self.id} Done.")
|
print(f"Thread-{self.id} Done.")
|
||||||
|
|
||||||
|
def process_data(self):
|
||||||
def process_data(id, q):
|
|
||||||
while not exitFlag:
|
while not exitFlag:
|
||||||
queueLock.acquire()
|
queueLock.acquire()
|
||||||
if not workQueue.empty():
|
if not workQueue.empty():
|
||||||
data = q.get()
|
data = self.q.get()
|
||||||
queueLock.release()
|
queueLock.release()
|
||||||
print(f"Thread-{id} processing {data}")
|
print(f"Thread-{self.id} processing {data}")
|
||||||
else:
|
else:
|
||||||
queueLock.release()
|
queueLock.release()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue