0

I have installed Debian 8.5 (jessie) yesterday and now running even a very simple pygame program causes a python-CPU-usage of ca. 100% and gnome-shell uses also almost another 100%! The program i have tested which uses 100% CPU is the following:

import pygame
import random

SCREEN_SIZE=(500,500)
SCREEN=pygame.display.set_mode(SCREEN_SIZE)

surf=pygame.Surface((50,50))
surf.fill([random.randrange(256) for _ in range(3)])

SCREEN.blit(surf,(225,225))

pygame.display.flip()

performs_not=False
while not performs:
    for e in pygame.event.get():
        if e.type==pygame.QUIT or (e.type==pygame.KEYDOWN and e.key==pygame.K_ESCAPE):
            performs_not=True
pygame.quit()

Does any one have any idea why is this DISASTER happening?

  • I assume it's because you're in an infinite loop (until you quit). You probably want to either set a framerate with `clock = pygame.time.Clock(); clock.tick()` or a timer with `pygame.time.delay()`. – Isa Jul 07 '16 at 16:45
  • this is normal behavior on all platforms. Suppose you want to render animation to a file. Why would you limit the iteration speed then. – Mikhail V Jul 11 '16 at 22:29

0 Answers0