Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Fix AttributeError isAlive#2092

Merged
jacobperron merged 3 commits intoros:noetic-develfrom
BrutusTT:noetic-devel
Dec 30, 2020
Merged

Fix AttributeError isAlive#2092
jacobperron merged 3 commits intoros:noetic-develfrom
BrutusTT:noetic-devel

Conversation

@BrutusTT
Copy link
Copy Markdown
Contributor

@BrutusTT BrutusTT commented Nov 19, 2020

starting roscore results in:

exception in shutdown_process_monitor: 'ProcessMonitor' object has no attribute 'isAlive'
Traceback (most recent call last):
  File "/Users/brutustt/ros_catkin_ws/install_isolated/lib/python3.9/site-packages/roslaunch/pmon.py", line 116, in shutdown_process_monitor
    if process_monitor.isAlive():
AttributeError: 'ProcessMonitor' object has no attribute 'isAlive'

However, the ProcessMonitor has a is_alive method so I assume this is what was meant here.

The same happens after closing rqt:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/Users/ingo/ros_catkin_ws/src/ros_comm/rospy/src/rospy/core.py", line 615, in _ros_atexit
    signal_shutdown('atexit')
  File "/Users/ingo/ros_catkin_ws/src/ros_comm/rospy/src/rospy/core.py", line 598, in signal_shutdown
    if t.isAlive():
AttributeError: 'Thread' object has no attribute 'isAlive'

However, the Thread has a is_alive method so I assume this is what was meant here.

@pschmutz
Copy link
Copy Markdown

There are still a few usages of isAlive in the code:

tools/roslaunch/test/unit/test_roslaunch_pmon.py:57:    def isAlive(self):
tools/roslaunch/test/unit/test_roslaunch_pmon.py:305:        self.assert_(pmon.isAlive())
tools/roslaunch/test/unit/test_roslaunch_pmon.py:307:        self.failIf(pmon.isAlive())
tools/roslaunch/test/unit/test_roslaunch_pmon.py:324:        self.assert_(pmon1.isAlive())
tools/roslaunch/test/unit/test_roslaunch_pmon.py:325:        self.assert_(pmon2.isAlive())        
tools/roslaunch/test/unit/test_roslaunch_pmon.py:329:        self.failIf(pmon1.isAlive())
tools/roslaunch/test/unit/test_roslaunch_pmon.py:330:        self.failIf(pmon2.isAlive())        
clients/rospy/src/rospy/core.py:512:            if not other.isAlive():

It probably makes sense to change them as well.

I am not sure if the isAlive function in the ProcessMonitorMock is used externally. So it might make sense to keep it and just add an is_alive or create an alias for it.

@jacobperron jacobperron self-assigned this Dec 10, 2020
@jacobperron
Copy link
Copy Markdown
Contributor

jacobperron commented Dec 10, 2020

Thanks for the fix!

I agree with @pschmutz about updating the remaining instances as well.

I am not sure if the isAlive function in the ProcessMonitorMock is used externally. So it might make sense to keep it and just add an is_alive or create an alias for it.

+1 for keeping it and adding a new is_alive as needed.

@BrutusTT Do you mind updating this PR, replacing the other instances of isAlive as well?

Keep mock method isAlive to keep backwards compatibility for users who happen to be using the mock object.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Copy Markdown
Contributor

I went ahead an updated the remaining instances of 'isAlive' (0efe27b).

@jacobperron jacobperron merged commit 5f13bb3 into ros:noetic-devel Dec 30, 2020
nim65s added a commit to nim65s/ros-noetic-rospy that referenced this pull request Jan 22, 2021
fix:
```python
Traceback (most recent call last):
  File "…/lib/controller_manager/spawner", line 212, in <module>
    if __name__ == '__main__': main()
  File "…/lib/controller_manager/spawner", line 210, in main
    rospy.spin()
  File "/opt/ros/noetic/lib/python3.9/site-packages/rospy/client.py", line 129, in spin
    rospy.rostime.wallsleep(0.5)
  File "/opt/ros/noetic/lib/python3.9/site-packages/rospy/rostime.py", line 277, in wallsleep
    time.sleep(duration)
  File "/opt/ros/noetic/lib/python3.9/site-packages/rospy/core.py", line 602, in _ros_signal
    signal_shutdown("signal-"+str(sig))
  File "/opt/ros/noetic/lib/python3.9/site-packages/rospy/core.py", line 594, in signal_shutdown
    if t.isAlive():
AttributeError: 'Thread' object has no attribute 'isAlive'
```

ref: ros/ros_comm#2092
acxz pushed a commit to ros-noetic-arch/ros-noetic-rospy that referenced this pull request Jan 25, 2021
fix:
```python
Traceback (most recent call last):
  File "…/lib/controller_manager/spawner", line 212, in <module>
    if __name__ == '__main__': main()
  File "…/lib/controller_manager/spawner", line 210, in main
    rospy.spin()
  File "/opt/ros/noetic/lib/python3.9/site-packages/rospy/client.py", line 129, in spin
    rospy.rostime.wallsleep(0.5)
  File "/opt/ros/noetic/lib/python3.9/site-packages/rospy/rostime.py", line 277, in wallsleep
    time.sleep(duration)
  File "/opt/ros/noetic/lib/python3.9/site-packages/rospy/core.py", line 602, in _ros_signal
    signal_shutdown("signal-"+str(sig))
  File "/opt/ros/noetic/lib/python3.9/site-packages/rospy/core.py", line 594, in signal_shutdown
    if t.isAlive():
AttributeError: 'Thread' object has no attribute 'isAlive'
```

ref: ros/ros_comm#2092
fmauch added a commit to ros-melodic-arch/ros-melodic-rospy that referenced this pull request Apr 3, 2021
fmauch added a commit to ros-melodic-arch/ros-melodic-roslaunch that referenced this pull request Apr 3, 2021
jacobperron added a commit that referenced this pull request Apr 6, 2021
* fix: roscore -> AttributeError: 'ProcessMonitor' object has no attribute 'isAlive'

* Fix AttributeError: 'Thread' object has no attribute 'isAlive'

* Update remaining instances of isAlive to is_alive

Keep mock method isAlive to keep backwards compatibility for users who happen to be using the mock object.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

Co-authored-by: Jacob Perron <jacob@openrobotics.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants