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

python3.11 and roslogging (rospy.init_node) #2296

Open
pepipho opened this issue Nov 8, 2022 · 3 comments
Open

python3.11 and roslogging (rospy.init_node) #2296

pepipho opened this issue Nov 8, 2022 · 3 comments

Comments

@pepipho
Copy link

pepipho commented Nov 8, 2022

test.py

import rospy

print("initializing node")
rospy.init_node( 'listener' , anonymous = True )
print("done")

Expected behaviour: init ros node and print "Done".
Current behaviour: python3.11 test.py is stucked in init_node method on this part
rosgraph/roslogging.py

class RospyLogger(logging.getLoggerClass()):
    def findCaller(self, *args, **kwargs):
        """
        Find the stack frame of the caller so that we can note the source
        file name, line number, and function name with class name if possible.
        """
        file_name, lineno, func_name = super(RospyLogger, self).findCaller(*args, **kwargs)[:3]
        file_name = os.path.normcase(file_name)

        f = inspect.currentframe()
        if f is not None:
            f = f.f_back
        while hasattr(f, "f_code"):
            # Search for the right frame using the data already found by parent class.
            co = f.f_code
            filename = os.path.normcase(co.co_filename)
            if filename == file_name and f.f_lineno == lineno and co.co_name == func_name:
                break
            if f.f_back:
                f = f.f_back
pip show rospy
Name: rospy
Location: /opt/ros/noetic/lib/python3/dist-packages
Version: 1.15.11
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal
@destroy314
Copy link

Same question. For me, I just add break on the end of while hasattr(f, "f_code"):

@jspricke
Copy link
Member

jspricke commented Mar 22, 2023

See 685a96e

Part of #2297

@Zhao-hangtian
Copy link

Same question. For me, I just add break on the end of while hasattr(f, "f_code"):

thx! it works ... but will it bring other proplem ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants