Application is blocked by import calls within functions

Issue #236 new
Allan Horn
created an issue

I've created a windows application using pyqt and froze it using Cx_Freeze. One part of the application is reliant upon the library comtypes which is essential for me to integrate with an externally provided DLL.

Prior to building, everything works fine with comtypes and I'm able to use interact with DLL successfully. After freezing the code, I'm running into an issue upon calling the "comtypes.GetModule" function. This function has a helper function called "_my_import" which is where I've isolated the problem.

The function is the following:

def _my_import(fullname):
    # helper function to import dotted modules
    import comtypes.gen
    if comtypes.client.gen_dir \
           and comtypes.client.gen_dir not in comtypes.gen.__path__:
        comtypes.gen.__path__.append(comtypes.client.gen_dir)
    return __import__(fullname, globals(), locals(), ['DUMMY'])

Once this function is called, it stops at the first import and blocks the remainder of the code. I've let the application sit there for several minutes and the import never completes nor does it ever throw an error. Once i comment the first import out and and move it to the top, the application proceeds until reaching the return function which is also attempting an import. Similarly, I commented that out and manually imported the desired module at the top and now the application runs as expected.

I've tried replicating the issue by importing comtypes.gen in a different module but that import occurred successfully. I've attached a log of my build.

Comments (2)

  1. Log in to comment