bugfix: Avoid removing modules added by Reactor from sys.modules.#194
Open
guyniv wants to merge 1 commit intoGourieff:mainfrom
Open
bugfix: Avoid removing modules added by Reactor from sys.modules.#194guyniv wants to merge 1 commit intoGourieff:mainfrom
sys.modules.#194guyniv wants to merge 1 commit intoGourieff:mainfrom
Conversation
Author
|
This PR solves #164 |
Usually when multiple files try to import a module, the first time will
trigger an import, and the imported module will be cached in
`sys.modules`. The second time an import happens it will get the module
from `sys.module`.
It appears that in `__init__.py` we remove any new module that was added
by Reactor, apart from a specific white list.
The meaning of this is that if a module has a side effect when we import
it, if the same module will be imported it won't find it in
`sys.module`, and the side effect will happen again.
To be specific, it causes an issue with `torchao`, which its import triggers the following line:
```
lib.define("int_matmul(Tensor a, Tensor b) -> Tensor")
```
Which will throw this error when it's execute twice:
```
RuntimeError: Tried to register an operator (torchao::int_matmul(Tensor a, Tensor b) -> Tensor) with the same name and overload name multiple times.
```
ab10d1c to
cb992b0
Compare
ChrisFab16
added a commit
to ChrisFab16/ComfyUI-ReActor
that referenced
this pull request
Feb 9, 2026
The cleanup code added in PR Gourieff#194 removes modules from sys.modules that other custom nodes depend on, causing segmentation faults. This fix removes the aggressive module cleanup while keeping path cleanup and a1111 webui module restoration. Also unpins versions for flexibility: - insightface>=0.7.3 - numpy>=1.26.4
Owner
|
Thanks for PR my friend |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intro:
Usually when multiple files try to import a module, the first time will trigger an import, and the imported module will be cached in
sys.modules. The second time an import happens it will get the module fromsys.modules.Why:
It appears that in
__init__.pywe remove any new module that was added by Reactor, apart from a specific white list.The meaning of this is that if a module has a side effect when we import it, and the same module will be imported in another place, python won't find it in
sys.modules, and the side effect will happen again.To be specific, it causes an issue with
torchao, which its import triggers the following line:Which will throw this error when it's imported the second time:
How to Reproduce:
To trigger a second import to
torchao, add this line to the end of__init__.py: