New Question
0

weird thing of ClassLoader, it's so slow using __import__

asked 2015-04-27 10:51:22 +0300

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I have encountered a weird thing in win2003.when we use ClassLoader to load cloudbaseinit.osutils.windows.WindowsUtils, sometime it takes more than 80 seconds. and it seems only happen in the first windows setup, when restart again, it just takes less than 1ms.

the code is here(it's the function of ClassLoader class):

def load_class(self, class_path):
        LOG.debug('Loading class \'%s\'' % class_path)
        parts = class_path.rsplit('.', 1)
        # *the __import__ function takes more than 80 seconds in the first time*
        module = __import__(parts[0], fromlist=parts[1])
        return getattr(module, parts[1])

The whole source code is from CloudbaseInitSetupBetax86.msi installation. Up to now, i can't tell it's a python thing or a cloudbase-init thing, can someone explain it?? If you need more information, please tell me. thanks very much.

edit retag flag offensive close merge delete

Comments

Are you using x86 or x64 images?

alexpilotti gravatar imagealexpilotti ( 2015-04-27 11:03:26 +0300 )edit

windows 2003 32bit system, it's x86

maofu.tian gravatar imagemaofu.tian ( 2015-04-27 11:25:36 +0300 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2015-04-30 02:17:36 +0300

updated 2015-04-30 02:21:27 +0300

It may be for sure an issue with the python-windows bindings and load of the requested DLLs.

Are you sure that you're using the latest installer? Can you reproduce the slow behavior by doing as few steps as possible (like reboot, then load - or - uninstalling cloudbase-init, cleaning up the registry/disk remnants, then installing and running the service again)? If yes, then tell us how and/or try replacing for yourself the line above "return" with this:

import importlib
module = importlib.import_module(parts[0])

To see if the function itself is the problem, but there are many chances that a simple import like:

from cloudbaseinit.osutils.windows import WindowsUtils

will have the same result. What are the accurate details of your platform (like os name, edition, service pack etc.)?

Also, keep in mind that Microsoft's Windows 2003 support will end in 75 days and ours too, so we can't do too much, especially due to the fact that the installer was tested against Windows Server 2003 x86 SP2 both Enterprise and Standard editions and we couldn't find such noticeable slow situations.

edit flag offensive delete link more

Comments

thanks a lot. we don't want try more energy on that since it just happen on first setup

maofu.tian gravatar imagemaofu.tian ( 2015-05-16 14:56:51 +0300 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-04-27 10:51:22 +0300

Seen: 535 times

Last updated: Apr 30 '15