|
|
|
|
|
by obtu
5276 days ago
|
|
You're listening for two file descriptor events, so you need some sort of event loop. select can do it but it's low-level; and since there can be only one event loop per program, your choices are frameworks and not simply libraries. Here's a way to do it with Twisted (docs here: http://twistedmatrix.com/documents/current/core/howto/proces... ): from twisted.internet import reactor, protocol
class PrintAndLogProtocol(protocol.ProcessProtocol):
def outReceived(self, data):
# print and log
errReceived = outReceived
reactor.spawnProcess(PrintAndLogProtocol(),
'/path/to/exe', ['exe', 'arg1', 'arg2'])
reactor.run()
|
|