Why does calling a class in (python) pyglet.image cause heavy CPU usage on Windows?

I am using the pyglet python module (python 3 on windows). When I refer to any classes in pyglet.image, using the python processor jumps up and doesn't crash until I exit python. For example:

Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Anaconda3>python.exe Python 3.4.3 |Anaconda 2.3.0 (64-bit)| (default, Mar 6 2015, 12:06:10) [MSC v.1 600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pyglet #No problem! >>> pyglet.image.ImageData #Heavy CPU load until I exit python <class 'pyglet.image.ImageData'> 

Is this the expected behavior? Why does the mention of this class (not even its creation) lead to such a high processor load?

Systems I tested:

  • Windows 7 desktop with Anaconda python 3.4.3 installed and pyglet via "pip install pyglet": high CPU usage (my problem)

  • The same Win7 desktop with Anaconda python 3.4.3, but the piglet is installed via 'pip install hg + https://bitbucket.org/pyglet/pyglet ': high CPU usage.

  • The same Win7 desktop with python 3.5 from python.org and pyglet installed via "pip install pyglet": high CPU usage.

  • Lenovo Fedora 22 for laptop with python 3.4.2 and pyglet 1.2.1 installed via dnf: no problem.

  • Windows 10 HP laptop with Anaconda python 3.4 and pyglet installed via "pip install pyglet": no problem.

Is it possible that this is hardware dependent?

+7
python debugging windows cpu pyglet
source share
1 answer

This is likely due to the following lines in the module :

 # Initialise default codecs from pyglet.image import codecs as _codecs _codecs.add_default_image_codecs() 

The default download order for codecs is :

 # Add the codecs we know about. These should be listed in order of # preference. This is called automatically by pyglet.image. # Compressed texture in DDS format try: from pyglet.image.codecs import dds add_encoders(dds) add_decoders(dds) except ImportError: pass # Mac OS X default: QuickTime (...) # Windows XP default: GDI+ (...) # Linux default: GdkPixbuf 2.0 (...) # Fallback: PIL (...) # Fallback: PNG loader (slow) (...) # Fallback: BMP loader (slow) (...) 

Due to lazy loading, pyglet.image only loads when you link to something, and you are probably using one of the slow backups. If so, perhaps you can try installing / removing codecs so that you use them one at a time and find out if the problem is with the codecs. Publishing versions of these codecs can help reproduce the issue.

+2
source share

All Articles