Skip to content

Commit

Permalink
Update finder.py to fix RecursionError: maximum recursion depth exceeded
Browse files Browse the repository at this point in the history
if module is to much , RecursionError: maximum recursion depth exceeded , fix to scan_code new one thread
  • Loading branch information
WoolenWang authored and marcelotduarte committed Mar 22, 2024
1 parent 5785f7f commit 16a99c2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cx_Freeze/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,18 +462,25 @@ def _load_module_code(
if module.hook:
module.hook(self)

import threading
if module.code is not None:
if self.replace_paths:
module.code = self._replace_paths_in_code(module)

# Scan the module code for import statements
self._scan_code(module, deferred_imports)
# self._scan_code(module, deferred_imports)
thr = threading.Thread(target=self._scan_code, args=(module, deferred_imports))
thr.start()
thr.join()

# Verify __package__ in use
module.code = self._replace_package_in_code(module)

elif module.stub_code is not None:
self._scan_code(module, deferred_imports, module.stub_code)
# self._scan_code(module, deferred_imports, module.stub_code)
thr = threading.Thread(target=self._scan_code, args=(module, deferred_imports, module.stub_code))
thr.start()
thr.join()

module.in_import = False
return module
Expand Down

0 comments on commit 16a99c2

Please sign in to comment.