Skip to content
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

rqt_top: Restarted nodes do not reappear #294

Closed
odel4y opened this issue Dec 11, 2014 · 3 comments
Closed

rqt_top: Restarted nodes do not reappear #294

odel4y opened this issue Dec 11, 2014 · 3 comments
Labels

Comments

@odel4y
Copy link

odel4y commented Dec 11, 2014

The process monitor plugin fails to redisplay nodes that have been killed and restarted while it is running. The cause seems to be in node_info.py:

  • Nodes that are killed during runtime do not get removed from self.nodes. A solution would be to define a method to check for obsolete nodes like so:
def remove_dead_nodes(self):
    running_nodes = rosnode.get_node_names()
    dead_nodes = [node_name for node_name in self.nodes if node_name not in running_nodes]
    for node_name in dead_nodes:
        self.nodes.pop(node_name, None)

and call that method in every get_all_node_info()

  • Restarted nodes change their uri but the module rosnode does not automatically reflect that change in its cached rosnode.get_api_uri() call. In the following the process monitor is unable to find the restarted process and does not display it.
    I would suggest to rebuild that cache in case of error like so:
def get_node_info(self, node_name, skip_cache=False):
    node_api = rosnode.get_api_uri(rospy.get_master(), node_name, skip_cache=skip_cache)
    try:
        code, msg, pid = xmlrpclib.ServerProxy(node_api[2]).getPid(ID)
        if node_name in self.nodes:
            return self.nodes[node_name]
        else:
            try:
                p = psutil.Process(pid)
                self.nodes[node_name] = p
                return p
            except:
                return False
    except xmlrpclib.socket.error,e:
        if not skip_cache:
            return self.get_node_info(node_name, skip_cache=True)
        else:
            return False
@ablasdel
Copy link
Contributor

The approach looks sound. Would you mind making a pull request of the proposed change?

@odel4y
Copy link
Author

odel4y commented Dec 15, 2014

I created a pull request: #295

@ablasdel ablasdel added the bug label Jan 7, 2015
@ablasdel
Copy link
Contributor

ablasdel commented Jan 7, 2015

merge of #295 fixed this

@ablasdel ablasdel closed this as completed Jan 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants