[issue44415] sys.stdout.flush and print() hanging

2021-06-13 Thread Rajeev Chaurasia


New submission from Rajeev Chaurasia :

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@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 
<https://bugs.python.org/issue44415>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44415] sys.stdout.flush and print() hanging

2021-06-14 Thread Rajeev Chaurasia


Rajeev Chaurasia  added the comment:

self.logger = lib.logger.Log()

We have cronjob entry to call the application everyday
$crontab -e
0 1 * * * /scratch/rajeev/cronjob/exachk.sh

exachk.sh makes call to my python application as-
python3 /opt/oracle.ahf/exachk/exachk.py

Yes I am redirecting stdout to-

sys.stdout = lib.debugger.Tee("/tmp/exachk_screen_output_061321_23211.log")

I am not redirecting stderr anywhere.

--

___
Python tracker 
<https://bugs.python.org/issue44415>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44415] sys.stdout.flush and print() hanging

2021-06-15 Thread Rajeev Chaurasia


Rajeev Chaurasia  added the comment:

Thanks a lot Serhiy.
Your suggested fix resolved the issue.
-Rajeev

--
stage:  -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue44415>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44433] processes created by subprocess.Popen is not terminating

2021-06-16 Thread Rajeev Chaurasia


New submission from Rajeev Chaurasia :

I am using Linux OS and using multiprocessing in my application.

The child process execution get completed but the processes are not terminating.


childprocess = "/opt/oracle.ahf/exachk/exachk -silentforce -showpass -dball 
-nocvu -autorun_id DEFAULT -localonly -sudo_remoterun 0"

session = subprocess.Popen(childprocess, shell = True)
session.communicate()  

>From the log I can see execution of childprocess scripts(exachk and exachk.py) 
>is completed successfully but the process remains alive forever. Also the 
>parent process from where I am using subprocess.Popen that also remains alive.

# ps -ef|grep exachk
(P1) 278988 247699  0 18:46 ?00:00:00 sh 
/opt/oracle.ahf/exachk/exachk -silentforce -showpass -dball -nocvu -autorun_id 
DEFAULT -localonly -sudo_remoterun 0
(P2) 279873 278988 39 18:46 ?00:12:51 
/opt/oracle.ahf/python/bin/python /opt/oracle.ahf/exachk/exachk.py -silentforce 
-showpass -dball -nocvu -autorun_id DEFAULT -localonly


Please help!
-Rajeev

--
components: Library (Lib)
messages: 395909
nosy: rajeevkchaurasia
priority: normal
severity: normal
status: open
title: processes created by subprocess.Popen is not terminating
versions: Python 3.8

___
Python tracker 
<https://bugs.python.org/issue44433>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com