High CPU usage in pygame

Issue #331 new
Maksym Planeta
created an issue

Hello,

I have a following snippet of code:

pygame.init()
import time
time.sleep(50)

When the scripts goes sleep, I observe high CPU utilization.

I tracked this down to sound system, and when I add pygame.mixer.quit() after init, script utilizes CPU as expected. I figured out that pygame creates a new process, which eats up all the CPU and the backtrace of this thread looks as follows (this is how I pointed problem to sound mixer):

(gdb) bt
#0  0x00007f297504554d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f295e16107e in ?? () from /usr/lib/x86_64-linux-gnu/libasound.so.2
#2  0x00007f295e165fb8 in ?? () from /usr/lib/x86_64-linux-gnu/libasound.so.2
#3  0x00007f295e1a60c8 in ?? () from /usr/lib/x86_64-linux-gnu/libasound.so.2
#4  0x00007f29748c9fc5 in ALSA_PlayAudio (this=0x5633de70d990) at ./src/audio/alsa/SDL_alsa_audio.c:321
#5  0x00007f297489ed90 in SDL_RunAudio (audiop=audiop@entry=0x5633de70d990) at ./src/audio/SDL_audio.c:215
#6  0x00007f29748a6f58 in SDL_RunThread (data=0x5633de686360) at ./src/thread/SDL_thread.c:204
#7  0x00007f29748e79d9 in RunThread (data=<optimized out>) at ./src/thread/pthread/SDL_systhread.c:47
#8  0x00007f2975e5a424 in start_thread (arg=0x7f295622e700) at pthread_create.c:333
#9  0x00007f297504e9bf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:105

Python version: 3.5.3 libasound2 version: 1.1.3-4 (Debian testing)

Comments (3)

  1. Thomas Kluyver

    I can reproduce this if I install from a wheel from PyPI, but not if I install pygame from source. That points to some error with the packaging - maybe an issue with the old ALSA library that it's built with. Possibly we need to try building a newer version of ALSA from source.

  2. Log in to comment