Merge pull request #49 from iPAS/fix_defunct

To prevent the native /webserver/core/openplc getting defunct
This commit is contained in:
Thiago Alves 2019-04-25 08:55:35 -07:00 committed by GitHub
commit 8731dcbe00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
# where docs are output to on gitlab.. MUST be named public/
public/

View File

@ -76,7 +76,7 @@ class runtime:
def start_runtime(self):
if (self.status() == "Stopped"):
a = subprocess.Popen(['./core/openplc'])
self.theprocess = subprocess.Popen(['./core/openplc']) # XXX: iPAS
self.runtime_status = "Running"
def stop_runtime(self):
@ -88,6 +88,10 @@ class runtime:
data = s.recv(1000)
s.close()
self.runtime_status = "Stopped"
while self.theprocess.poll() is None: # XXX: iPAS, to prevent the defunct killed process.
time.sleep(1) # https://www.reddit.com/r/learnpython/comments/776r96/defunct_python_process_when_using_subprocesspopen/
except socket.error as serr:
print("Failed to stop the runtime. Error: " + str(serr))