#๐ Need help with python subprocess
36 messages ยท Page 1 of 1 (latest)
@lime hedge
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Problem is not knowing if something is an stdout or stderr I have to look out for
And it also doesnt make sense that the whole program won't give me outputs at all altho I have my print(newoutline)
Tried printing the errline as well?
Yep same result
the output worked when i just had
def execute(f):
process = Popen(f, stdout=PIPE, bufsize=1, universal_newlines=True, encoding="utf8")
process.poll()
print("Running Binmaster-Slayer...")
while True:
nextline = process.stdout.readline()
print(nextline)
if 'Stall detected but the heartbeat check is still active!' in nextline and process.poll() is not None:
print("Restarting Binmaster-Slayer because of stalling...")
process.exit()
time.sleep(5)
execute(f)
elif 'Uncaught Exception:' in nextline and process.poll() is not None:
print("Restarting Binmaster-Slayer because of Uncaught Exception Error...")
process.exit()
time.sleep(5)
execute(f)
execute(f)
But it wouldn't exit and restart on the specified outputs
@rapid dove you have any ideas on how I could change it so it'll work?
Output worked, meaning something got printed... So just adding the pipe of stderr stops the prints?
yes it is really weird
But no, just Piping the stderr is not the problem
This code like gives outputs but doesnt restart the program
on the specified errors or line contents
Okay now its really weird
Its just outputting the first line
WTF
Tried communicate instead of readline?
Yea, should return a tuple. With both out and err output
Do I have to fill in args in the communicate function?
No, I'd see just what communicate() returns
These are the latest tracebacks, output is nothing
Just this
Do I have to decode it or smth?
Like the lines
prob does that automatically right since I alredy had to specify "utf8"
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.