use six.StringIO for compatibility with io.StringIO in python3
The newer version of six (1.4.1) provides six.StringIO which is a fake file object for textual data. It's an alias for cStringIO.StringIO, in python2 and io.StringIO in Python3 Change-Id: Ia2c8f8472a0327c2e1d19cc889940bdfdab8dd8a
This commit is contained in:
parent
6f3e984ca0
commit
ac3649c0d8
@ -5,7 +5,9 @@
|
||||
import glob
|
||||
import logging
|
||||
import os
|
||||
import pstats
|
||||
import signal
|
||||
import six
|
||||
import sys
|
||||
import time
|
||||
|
||||
@ -97,7 +99,7 @@ class CollectorDaemon(monasca_agent.common.daemon.Daemon):
|
||||
collection_start = time.time()
|
||||
# enable profiler if needed
|
||||
profiled = False
|
||||
if config.get('profile', False) and config.get('profile').lower() == 'yes':
|
||||
if config.get('profile', False):
|
||||
try:
|
||||
import cProfile
|
||||
profiler = cProfile.Profile()
|
||||
@ -111,12 +113,10 @@ class CollectorDaemon(monasca_agent.common.daemon.Daemon):
|
||||
self.collector.run(check_frequency)
|
||||
|
||||
# disable profiler and printout stats to stdout
|
||||
if config.get('profile', False) and config.get('profile').lower() == 'yes' and profiled:
|
||||
if config.get('profile', False) and profiled:
|
||||
try:
|
||||
profiler.disable()
|
||||
import cStringIO
|
||||
import pstats
|
||||
s = cStringIO.StringIO()
|
||||
s = six.StringIO()
|
||||
ps = pstats.Stats(profiler, stream=s).sort_stats("cumulative")
|
||||
ps.print_stats()
|
||||
log.debug(s.getvalue())
|
||||
|
Loading…
Reference in New Issue
Block a user