Workaround the epoll_wait(timeout..) cpu usage

Increase sleep in the fifo polling a bit (saves a few % cpu)
Change the worker process queue to block on get and timeout quickly after 1s
This makes the script use about 0%cpu while idle instead of 100%
This commit is contained in:
Guillaume Destuynder 2014-04-30 18:35:30 -07:00
Родитель 372f2a7764
Коммит ec21a82fa0
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -143,7 +143,7 @@ def postLogs(logcache):
try:
#see if we have anything to post
#waiting a bit to not end until we are told we can stop.
postdata=logcache.get(False,30)
postdata=logcache.get(True,1)
if postdata is None:
#signalled from parent process that it's ok to stop.
logcache.task_done()
@ -292,7 +292,7 @@ def main():
bufa.append(buf)
else:
#non read event occurred, wait a bit and poll again.
time.sleep(.001)
time.sleep(.01)
if '\n' in ''.join(bufa):
@ -345,4 +345,4 @@ if __name__ == '__main__':
(options,args) = parser.parse_args()
initConfig()
initLogger()
main()
main()