-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathWebMCPProcessor.py
47 lines (38 loc) · 1.46 KB
/
WebMCPProcessor.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from __main__ import socketio
import time
from DataStructures.makesmithInitFuncs import MakesmithInitFuncs
class WebMCPProcessor(MakesmithInitFuncs):
"""
This class is deprecated as shifting away from WebMCP.
"""
app = None
def start(self, _app):
print("Starting WebMCP Queue Processor")
self.app = _app
self.data.webMCPActive = True
while True:
time.sleep(0.001)
while not self.data.mcp_queue.empty(): # if there is new data to be read
message = self.data.mcp_queue.get()
# print("MCP Queue:"+message)
if self.app is not None:
with self.app.app_context():
# print("Emitting:"+message)
socketio.emit(
"webcontrolMessage", {"data": message}, namespace="/WebMCP"
)
def connect(self, _app):
self.app = _app
class ConsoleProcessor(MakesmithInitFuncs):
def start(self):
print("Starting Console Queue Processor")
while True:
time.sleep(0.001)
while (
not self.data.console_queue.empty()
): # if there is new data to be read
message = self.data.console_queue.get()
print(message)
if self.data.webMCPActive:
# print("putting message in mcp_queue")
self.data.mcp_queue.put(message)