-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for module import issue #360
Conversation
adec9be
to
a30f4ad
Compare
@hidmic Here's the fix. It's more explanation than code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is ok? Seems like a hack, but maybe it will help someone avoid a rough edge, though I wouldn't expect launch to do this for you, so it may be surprising either way.
@wjwwood launch gives the file a fixed module name "python_launch_file" so unless someone makes a module with the same name, launch will not encounter the same problem. I don't remember why 'launch' and 'launch_testing' don't use the same load_python_launch_file_as_module method. It's probably the result of launch_testing being developed against a frozen version of 'launch' back when it was apex_launchtest An alternative fix would be to have launch_testing use the same method as launch to import the test file - maybe import it as |
It is a bit of a hack, and I agree that it might silently incur in unwanted side effects. I didn't know of a superior alternative though, for the reasons that @pbaughman already mentioned in #357. Having said that, after digging a bit further into |
@hidmic I tried doing this:
But now things are blowing up here: https://github.com/ros2/launch/blob/master/launch_testing/launch_testing/loader.py#L154 with an error "module lidar_integration has no attribute 'generate_test_description' I think I've just reversed the problem. Before, it was looking in the test file for things that should be found in the real module. Now I think it's looking in the real module for things that should be found in the test file. |
Maybe the correct fix here is "don't name your test files the same thing as a real module" and a better warning/error message when you do. . . |
@hidmic Ah, no I was wrong. . . This does it:
|
Signed-off-by: Pete Baughman <[email protected]>
a30f4ad
to
43f883d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending green CI
Alright, all green. Going in! |
Signed-off-by: Pete Baughman <[email protected]>
Signed-off-by: Pete Baughman <[email protected]> Signed-off-by: Ivan Santiago Paunovic <[email protected]>
* Handle case where output buffer is closed during shutdown (#365) * Handle case where output buffer is closed during shutdown - Prevent crash during launch shutdown when a process IO event happens after the buffers have been closed - Use unbuffered output in that case so IO still has a chance of being seen Signed-off-by: Pete Baughman <[email protected]> * Address MR feedback Signed-off-by: Pete Baughman <[email protected]> Signed-off-by: Ivan Santiago Paunovic <[email protected]> * Import test file without contaminating sys.modules (#360) Signed-off-by: Pete Baughman <[email protected]> Signed-off-by: Ivan Santiago Paunovic <[email protected]> * Release loop lock before waiting for it to do work (#369) Main thread can be blocked trying to acquire __loop_from_run_thread_lock while emit_event() in another thread is holding that lock and waiting for the main thread to emit the event. This change releases the lock before blocking. Signed-off-by: Shane Loretz <[email protected]> Signed-off-by: Ivan Santiago Paunovic <[email protected]> Co-authored-by: Peter Baughman <[email protected]> Co-authored-by: Shane Loretz <[email protected]>
This prevents the source file loader from hiding the real module (if it exists)
in the sys.modules cache
Signed-off-by: Pete Baughman [email protected]
Closes #357