mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
fix no such directory error when running server
and added a 0.5 sleep time between disconnecting and killing server
This commit is contained in:
@@ -26,6 +26,7 @@ import webbrowser
|
|||||||
import asyncio
|
import asyncio
|
||||||
import socketio
|
import socketio
|
||||||
import threading
|
import threading
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
sio = None
|
sio = None
|
||||||
ws_process = None
|
ws_process = None
|
||||||
@@ -54,8 +55,12 @@ class Web(blenderbim.core.tool.Web):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def start_websocket_server(cls, port):
|
def start_websocket_server(cls, port):
|
||||||
global ws_process
|
global ws_process
|
||||||
ws_path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "webui", "sioserver.py")
|
|
||||||
ws_process = subprocess.Popen(["python", ws_path, "--p", str(port), "--host", "127.0.0.1"])
|
webui_path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "webui")
|
||||||
|
|
||||||
|
ws_path = os.path.join(webui_path, "sioserver.py")
|
||||||
|
|
||||||
|
ws_process = subprocess.Popen(["python", ws_path, "--p", str(port), "--host", "127.0.0.1"], cwd=webui_path)
|
||||||
cls.open_web_browser(port)
|
cls.open_web_browser(port)
|
||||||
cls.set_is_running(True)
|
cls.set_is_running(True)
|
||||||
|
|
||||||
@@ -98,9 +103,12 @@ class Web(blenderbim.core.tool.Web):
|
|||||||
if bpy.context.scene.WebProperties.is_connected:
|
if bpy.context.scene.WebProperties.is_connected:
|
||||||
cls.disconnect_websocket_server()
|
cls.disconnect_websocket_server()
|
||||||
|
|
||||||
|
sleep(0.5)
|
||||||
|
|
||||||
ws_process.terminate()
|
ws_process.terminate()
|
||||||
ws_process.wait()
|
ws_process.wait()
|
||||||
ws_process = None
|
ws_process = None
|
||||||
|
|
||||||
cls.set_is_running(False)
|
cls.set_is_running(False)
|
||||||
|
|
||||||
print("Websocket server terminated successfully")
|
print("Websocket server terminated successfully")
|
||||||
|
|||||||
Reference in New Issue
Block a user