Fix win10 not connecting to websocket server

pull/198/head
Davy Peter Braun 10 months ago
parent 8fca2645e7
commit 9c15d3f319

1271
software/poetry.lock generated

File diff suppressed because it is too large Load Diff

@ -24,6 +24,7 @@ import tempfile
from datetime import datetime
import cv2
import base64
import platform
from interpreter import interpreter # Just for code execution. Maybe we should let people do from interpreter.computer import run?
# In the future, I guess kernel watching code should be elsewhere? Somewhere server / client agnostic?
from ..server.utils.kernel import put_kernel_messages_into_queue
@ -58,6 +59,7 @@ CAMERA_WARMUP_SECONDS = float(os.getenv('CAMERA_WARMUP_SECONDS', 0))
# Specify OS
current_platform = get_system_info()
is_win10 = lambda: platform.system() == "Windows" and "10" in platform.version()
# Initialize PyAudio
p = pyaudio.PyAudio()
@ -252,9 +254,8 @@ class Device:
async def websocket_communication(self, WS_URL):
show_connection_log = True
while True:
try:
async with websockets.connect(WS_URL) as websocket:
async def exec_ws_communication(websocket):
if CAMERA_ENABLED:
print("\nHold the spacebar to start recording. Press 'c' to capture an image from the camera. Press CTRL-C to exit.")
else:
@ -305,6 +306,21 @@ class Device:
code = message["content"]
result = interpreter.computer.run(language, code)
send_queue.put(result)
if is_win10():
logger.info('Windows 10 detected')
# Workaround for Windows 10 not latching to the websocket server.
# See https://github.com/OpenInterpreter/01/issues/197
try:
ws = websockets.connect(WS_URL)
await exec_ws_communication(ws)
except Exception as e:
logger.error(f"Error while attempting to connect: {e}")
else:
while True:
try:
async with websockets.connect(WS_URL) as websocket:
await exec_ws_communication(websocket)
except:
logger.debug(traceback.format_exc())
if show_connection_log:

Loading…
Cancel
Save