Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

requests widget cpu issue

  • Loading branch information...
commit 3d8a45c4788cadb45219645f420aff629079a351 1 parent 120888e
@Eyjafjallajokull authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 widgets/requests/main.py
View
6 widgets/requests/main.py
@@ -1,3 +1,4 @@
+import time
from core.widget import BaseWidget
import os
from multiprocessing import Process, Value
@@ -11,6 +12,7 @@ def __init__(self, config={}):
return
file = open(self.config['file'])
+ file.seek(0, os.SEEK_END)
self.lines = Value('i', 0)
self.readerProcess = Process(target=reader, args=(self.lines, file))
self.readerProcess.start()
@@ -29,5 +31,5 @@ def collectData(self):
def reader(lines, stream):
while True:
- if stream.readline():
- lines.value += 1
+ lines.value += len(stream.readlines())
+ time.sleep(0.1)
Please sign in to comment.
Something went wrong with that request. Please try again.