You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Racket Users
I am running the system procedure in drracket's interactive window
(system "test.py")
where test.py is
#!/home/utils/Python-3.8.0/bin/python3
import os
print("Running cmd: date1")
print("Running cmd: date2")
os.system("date")
print("Running cmd: date3")
os.system("date")
and the output is
Tue May 19 22:14:19 PDT 2020
Tue May 19 22:14:19 PDT 2020
Running cmd: date1
Running cmd: date2
Running cmd: date3
#t
which is different from my expectation, can anyone help explain why?
Rock Nie
unread,
May 20, 2020, 4:15:02 AM5/20/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Racket Users
This only happens in DrRacket.
Alex Harsanyi
unread,
May 20, 2020, 4:49:30 AM5/20/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Racket Users
Short version: Try adding a "sys.stdout.flush()" after each of your print statements in your python script.
Longer version: when you run that program in a terminal, the output is a TTY and the standard output is flushed after every line. When you run it as a subprocess, the standard output is a pipe and it is buffered.
This is not Racket specific, you would get the same problem if you ran "os.system("test.py")" in another python program.
Alex.
Rock Nie
unread,
May 20, 2020, 5:00:12 AM5/20/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Racket Users
Thx! sys.stdout.flush() works but in real use cases I cannot add sys.stdout.flush() to every python print.
Can I do anything in the racket side to solve the problem? Making the interactive window behave like terminal perhaps?
Alex Harsanyi
unread,
May 20, 2020, 5:11:36 AM5/20/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message