2

I want to make python start a background process. I am trying to make a 1v1 chat and I don't know how to verify always if new messages come in. Is there a library I can do this with? Something like this:

def always(x):
    always program are running:
    if x != '': print x

while True:
    always(server.recv(1024))
    data = raw_input('>>>')
    client.send(data)
Drewness
  • 5,004
  • 4
  • 32
  • 50

1 Answers1

0

For your background process, I would create a subprocess.

import subprocess

process = subprocess.Popen(['your_background_command'])
stdoutdata, stderrdata = process.communicate()

Then you can use returncode to check on the status of the process.

print process.returncode
Drewness
  • 5,004
  • 4
  • 32
  • 50