0

I have a python script that launches an app using subprocess, but in order to communicate with it, I also use websockets (there's a plugin on the app that expects a server to communicate with). The code looks like:

#!python3
import os
import subprocess

import asyncio
import websockets

async def hello(websocket, path):
    name = await websocket.recv()
    print("< {}".format(name))

    greeting = "Hello {}!".format(name)
    await websocket.send(greeting)
    print("> {}".format(greeting))

start_server = websockets.serve(hello, 'localhost', 8765)

asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()

subprocess.call(['foo.exe', 'd:\\data\\foo_data.txt'])

The problem I have is that the process won't ever launch because the server's been started. Is it possible to use subprocess to launch an app and then return control to the parent process? Conversely is it possible to launch the server (and receiving messages) without looping forever?

easythrees
  • 1,530
  • 3
  • 16
  • 43

0 Answers0