You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a package utils in my project, probably not a very unique name I'm sure.
If I import stomp and then later try and import any code from my utils package, I get a mystical ImportError: No module named time.
After considerable effort I finally backtracked this error to stomp.
Stomp breaks my code because it modifies sys.path (which is bad enough as it is, for a library), by prepending (even worse) it's own path to it. This causes my previously ok code to break.
This works:
from utils.time import my_util_func
This does not:
import stomp
from utils.time import my_util_func
After importing stomp the utils actually resolves to utils.py inside stomp. I assume this same error will occur if anyone will try and use the names: adapter, backward2, backward3, backward, colors, connect, constants, exception, listener, protocol, or transport.
Most of those names don't seem that unique.
Worse yet, since the path change is done globally, it can break any seemingly unrelated code that is just executed after the import.
I can fix this myself by moving all of my code under another package, "myproject", and then use from myproject.utils.time import ..., but I wouldn't have to worry about this if stomp wasn't changing the path.
The text was updated successfully, but these errors were encountered:
Good point. No idea why that's (still) there. Suspect it was because of some issue in the distant past. However, if I remove it, other than having to reference stomp. everywhere, instead of just , doesn't look like there's any other negative side effects. So will fix in the next version.
I have a package utils in my project, probably not a very unique name I'm sure.
If I import stomp and then later try and import any code from my utils package, I get a mystical
ImportError: No module named time
.After considerable effort I finally backtracked this error to stomp.
Stomp breaks my code because it modifies sys.path (which is bad enough as it is, for a library), by prepending (even worse) it's own path to it. This causes my previously ok code to break.
This works:
This does not:
After importing stomp the utils actually resolves to utils.py inside stomp. I assume this same error will occur if anyone will try and use the names: adapter, backward2, backward3, backward, colors, connect, constants, exception, listener, protocol, or transport.
Most of those names don't seem that unique.
Worse yet, since the path change is done globally, it can break any seemingly unrelated code that is just executed after the import.
The issue is caused by these lines:
https://github.com/jasonrbriggs/stomp.py/blob/master/stomp/__init__.py#L12-L14
I can fix this myself by moving all of my code under another package, "myproject", and then use
from myproject.utils.time import ...
, but I wouldn't have to worry about this if stomp wasn't changing the path.The text was updated successfully, but these errors were encountered: