diff --git a/launch/launch/launcher.py b/launch/launch/launcher.py index 757affefd..239293fc6 100644 --- a/launch/launch/launcher.py +++ b/launch/launch/launcher.py @@ -391,21 +391,3 @@ def _print_process_stacktrace(self, name, future, exception): print('(%s)' % name, ' ' + line.strip(), file=sys.stderr) print('(%s) %s: %s' % (name, type(exception).__name__, str(exception)), file=sys.stderr) - - -class AsynchronousLauncher(threading.Thread): - - def __init__(self, launcher): - super(AsynchronousLauncher, self).__init__() - self.launcher = launcher - - def terminate(self): - self.launcher.interrupt_launch() - - def run(self): - if os.name != 'nt' and not isinstance(threading.current_thread(), threading._MainThread): - # explicitly create event loop when not running in main thread - loop = asyncio.new_event_loop() - asyncio.set_event_loop(loop) - - self.launcher.launch() diff --git a/launch/test/test_interrupt_asynchronous_launcher.py b/launch/test/test_interrupt_asynchronous_launcher.py deleted file mode 100644 index 70f08b546..000000000 --- a/launch/test/test_interrupt_asynchronous_launcher.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2016 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import sys - -from launch import LaunchDescriptor -from launch.launcher import AsynchronousLauncher -from launch.launcher import DefaultLauncher - - -def test_interrupt_asynchronous_launcher(): - desc = LaunchDescriptor() - desc.add_process( - cmd=[sys.executable, '-c', 'import time', 'time.sleep(30)'], - name='test_interrupt_asynchronous_launcher__python_blocking' - ) - - launcher = DefaultLauncher() - launcher.add_launch_descriptor(desc) - async_launcher = AsynchronousLauncher(launcher) - async_launcher.start() - - # wait up to 10 seconds to get to the point where at least all of the - # asyncio-subprocess coroutines have been run (the processes are still - # not guaranteed to be running yet) - launcher.wait_on_processes_to_spawn(10) - if not launcher.are_processes_spawned(): - # if the processes didn't launch after 10 seconds, fail the test - assert False, 'launcher never reported processes launched' - async_launcher.terminate() - # now wait for the launcher to finish and error if if doesn't - async_launcher.join(60) - if async_launcher.is_alive(): - # if still running fail the test - assert False, 'async launcher failed to shutdown' diff --git a/launch/test/test_module_level_launch.py b/launch/test/test_module_level_launch.py deleted file mode 100644 index 555a7da94..000000000 --- a/launch/test/test_module_level_launch.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import sys -import time - -from launch import LaunchDescriptor -from launch.launcher import AsynchronousLauncher -from launch.launcher import DefaultLauncher -from launch.loader import load_launch_file - -async_launcher = None - - -def setup(): - global async_launcher - default_launcher = DefaultLauncher() - - launch_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'launch_counter.py') - launch_descriptor = LaunchDescriptor() - load_launch_file(launch_file, launch_descriptor, {}) - default_launcher.add_launch_descriptor(launch_descriptor) - - async_launcher = AsynchronousLauncher(default_launcher) - async_launcher.start() - - -def teardown(): - global async_launcher - if async_launcher: - async_launcher.join() - - -def test_one(): - print('one', file=sys.stderr) - time.sleep(1) - - -def test_two(): - print('two', file=sys.stderr) - time.sleep(1) - - -def test_three(): - print('three', file=sys.stderr) - time.sleep(1) - - -if __name__ == '__main__': - setup() - teardown()