Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cProfile debugging
#1
Have some basic code that loops through a set of databases and assigns a count to a python list.
At end I just make a sum of that python list.
The sum seems to be where its really slow - which is strange as the list size is only around 10.

#code
import os
#import cProfile
from subprocess import Popen, PIPE

totalram=[]

lst = os.popen("ps -eaf | grep pmon | grep -iv $$ | egrep -iv 'ASM|APX' | sed 's?ora_pmon_??g' | awk '{print $NF}'").read()
lst = lst.split('\n')
for each in lst:
        sqlplus = Popen(["sqlplus", "-S", "/", "as", "sysdba"], stdout=PIPE, stdin=PIPE)
        sqlplus.stdin.write("set head off;"+os.linesep)
        sqlplus.stdin.write("select count(*) from all_objects;"+os.linesep)
        out ,err= sqlplus.communicate()
        print out
        totalram.append(int(out))

print (sum(totalram))
54 0.000 0.000 0.000 0.000 subprocess.py:772(_check_timeout)
1 0.000 0.000 0.000 0.000 traceback.py:1(<module>)
1 0.000 0.000 0.000 0.000 {_sre.compile}
118 0.000 0.000 0.000 0.000 {built-in method match}
54 7.453 0.138 7.453 0.138 {built-in method poll} <====== SLOW here - but what to do about it ?
27 0.000 0.000 0.000 0.000 {built-in method register}
27 0.000 0.000 0.000 0.000 {built-in method unregister}
1 0.000 0.000 0.000 0.000 {dir}

nevermind ....... it just "appeared" on my screen it was slow on the SUM function.
Its just slow on the loop iteration.

Anyone got a good link/video/url for debugging python errors outside of PDB .... I use pycharm but newbie
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pygame and cProfile MuntyScruntfundle 0 1,421 Feb-06-2019, 07:00 PM
Last Post: MuntyScruntfundle

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020