forked from markfinger/python-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
27 lines (22 loc) · 750 Bytes
/
Copy path__init__.py
File metadata and controls
27 lines (22 loc) · 750 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
import os
import atexit
import subprocess
process = subprocess.Popen(
args=('node', os.path.join(os.path.dirname(__file__), 'test_server.js'),),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
# Ensure the process is killed on exit
atexit.register(lambda _process: _process.kill(), process)
def read_line():
return process.stdout.readline().decode('utf-8')
output = read_line()
if output.strip() == '':
output += read_line()
if 'React render server' not in output:
if 'module.js' in output:
line = read_line()
while line:
output += line + os.linesep
line = read_line()
raise Exception('Unexpected output from render server subprocess...' + os.linesep + os.linesep + output)