forked from fhorinek/adbmirror
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy paththreadqueue.py
More file actions
32 lines (26 loc) · 720 Bytes
/
threadqueue.py
File metadata and controls
32 lines (26 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import threading
from multiprocessing import Queue
class ThreadedInOutQueue(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.q_in = Queue()
self.q_out = Queue()
def read(self):
msgs = []
try:
while True:
msgs.append(self.q_out.get(False))
finally:
return msgs
return msgs
def write(self, data):
self.q_in.put(data)
def internal_read(self):
msgs = []
try:
while True:
msgs.append(self.q_in.get(False))
finally:
return msgs
def internal_write(self, data):
self.q_out.put(data)