wistful / SublimeAutoPEP8

Automatically formats Python code to conform to the PEP 8 style guide using autopep8 and pep8 modules
144 stars 23 forks source link

plug_host.exe cpu run out of its thread/core #47

Closed ruiruige closed 7 years ago

ruiruige commented 7 years ago

My computer has 4 thread

When I format the following code (ctrl shift 8), the plug_host.exe using 25% CPU , and the code will never be formatted

image

the code is here:

`

def flush(self):
    for cpnt_name in self.excels:
        dct = self.excels[cpnt_name]
        cols = dct["cols"]
        fp = dct["fp"]

        workbook = xlsxwriter.Workbook(fp)
        worksheet = workbook.add_worksheet("Sheet1")
        bold = workbook.add_format({'bold': 1})

        chart_dict = {}

        # 选取第一列的行数,作为采集的次数,采集间隔暂时不管
        col_len = len(cols[0])     
        # 每一列代表一个主机
        for i in xrange(len(cols)):
            col = cols[i]

            hostname = col[0]
            for j in xrange(len(col)):
                worksheet.write(j, i, col[j])

            chart = workbook.add_chart({'type':'line'})    #定义一个line图表
            chart_dict[hostname] = chart

            chart.add_series({
                'categories':'=Sheet1!$A$20:$A$21',         #项目名
                'values':    '=Sheet1!$B$20:$B$21',         #值名
                'name' :                                    #表名 
            })

        MemChart.set_title({'name':'Memory Usage'})      #设置标题
        worksheet.insert_chart('A23',MemChart)           #插入图表

        # Add the worksheet data that the charts will refer to.
        headings = ['Number', 'Batch 1', 'Batch 2']

        data = [
            [2, 3, 4, 5, 6, 7],
            [10, 40, 50, 20, 10, 50],
            [30, 60, 70, 50, 40, 30],
        ]

        # # Create a new chart object. In this case an embedded chart.
        chart = workbook.add_chart({'type': 'line'})

        # Configure second series. Note use of alternative syntax to define
        # ranges.
        chart.add_series({
            'name':       ['Sheet1', 0, 2],
            'categories': ['Sheet1', 1, 0, 6, 0],
            'values':     ['Sheet1', 1, 2, 6, 2],
        })

        # # Add a chart title and some axis labels.
        # chart1.set_title({'name': 'Results of sample analysis'})
        # chart1.set_x_axis({'name': 'Test number'})
        # chart1.set_y_axis({'name': 'Sample length (mm)'})

        # # Set an Excel chart style. Colors with white outline and shadow.
        # chart1.set_style(10)

        # # Insert the chart into the worksheet (with an offset).
        # worksheet.insert_chart(
        #     'D2', chart1, {'x_offset': 25, 'y_offset': 10})

        workbook.close()

`

wistful commented 7 years ago

Hi @ruiruige! Thanks for reporting the issue.

I was able to reproduce the issue, and added logging to the dev version of the plugin to troubleshoot it. Unfortunately, I couldn't reproduce the issue after several editor restarts(was necessary to test logging).

Could you please try new version(1.3.4) of the plugin and let me know whether the issue still reproduces for you or not?

wistful commented 7 years ago

Feel free to reopen the issue if you still experience high CPU usage.