[New-bugs-announce] [issue44415] sys.stdout.flush and print() hanging
Rajeev Chaurasia
report at bugs.python.org
Mon Jun 14 00:36:52 EDT 2021
New submission from Rajeev Chaurasia <rajeevsgsits at gmail.com>:
I am running an application using cronjob. This application runs on Linux(X86_64) platform where inside a loop we have print() and sys.stdout.flush() statements. This loop iterates around 500 times and after the loop we have few more sys.stdout.flush() and print() statements.
When I am running same application on terminal (without cronjob) then it is working fine.
Inside the loop everything is working fine but application is hanging after the loop. I put some debug statements and I found it is hanging on print() and sys.stdout.flush().
Code logic:-
for x in range(500):
print(x)
print ("something")
sys.stdout.flush()
self.logger.info("A")
sys.stdout.flush() #1
self.logger.info("B")
print ("Hello") #2
self.logger.info("C")
print ("Bye") #3
self.logger.info("D")
-----------------------------------------
"A" is getting printed in log file and nothing after that but-
If I comment #1 then I get "B" as well in the log file.
If I comment #2 then I get "C" as well in the log file
If I comment #3 then I get "D" as well in the log file.
-----------------------------------------
ps results-
[root at scao05adm07 ~]# ps -ef|grep exachk
root 239265 98963 0 Jun11 ? 00:00:00 sh /opt/oracle.ahf/bin/exachk -silentforce -showpass -dball -nocvu -autorun_id DEFAULT
root 239706 239265 0 Jun11 ? 00:00:35 /opt/oracle.ahf/python/bin/python /opt/oracle.ahf/exachk/exachk.py -silentforce -showpass -dball -nocvu -autorun_id DEFAULT
root 277938 239706 0 Jun11 ? 00:00:00 sh /opt/oracle.ahf/exachk/exachk -silentforce -showpass -dball -nocvu -autorun_id DEFAULT -localonly -sudo_remoterun 0
root 278989 277938 0 Jun11 ? 00:12:26 /opt/oracle.ahf/python/bin/python /opt/oracle.ahf/exachk/exachk.py -silentforce -showpass -dball -nocvu -autorun_id DEFAULT -localonly -sudo_remoterun 0
root 281983 278989 0 Jun11 ? 00:00:27 /opt/oracle.ahf/python/bin/python /opt/oracle.ahf/exachk/exachk.py -silentforce -showpass -dball -nocvu -autorun_id DEFAULT -localonly -sudo_remoterun 0
-----------------------------------------
# uname -a
Linux ************ 4.14.35-1902.306.2.2.el7uek.x86_64 #2 SMP Thu Nov 19 18:09:09 PST 2020 x86_64 x86_64 x86_64 GNU/Linux
-----------------------------------------
I believe this issue is related to standard output buffer but I am not able to find a fix for it.
Please help.
-Rajeev
----------
components: Library (Lib)
messages: 395772
nosy: rajeevkchaurasia
priority: normal
severity: normal
status: open
title: sys.stdout.flush and print() hanging
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44415>
_______________________________________
More information about the New-bugs-announce
mailing list