By importing rosbag the standard logger is overwritte.
When sending a warning or error the logger is stuck in an indefinte loop.
This can cause other python libraries to malfunction (for example Flask).
To reproduce
import rosbag
import logging
logger = logging.getLogger('myLogger') # gets a RospyLogger object
logger.warn('message') # gets stuck in infinite loop
Infinite Loop is inside def findCaller(self, *args, **kwargs): in roslogging.py.
Afterwards it tries to find a matching stackframe (skipping the first), but there is none.
The loop to do so is a while loop, but the condition does not change, as f is not reassigned if the last frame is reached.
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
There are two things to fix:
Change the super().findCaller() so it does not return itself rather than the intended function. (Maybe stacklevel)
Prevent infinite loop by adding a else statement that does something (Throw Error?)
Alternativly do not set the global Logging class to RaspyLogger.
By importing rosbag the standard logger is overwritte. When sending a warning or error the logger is stuck in an indefinte loop. This can cause other python libraries to malfunction (for example Flask). To reproduce
Infinite Loop is inside
def findCaller(self, *args, **kwargs):
in roslogging.py.Cause of the issue is:
returns itself as the caller:
Afterwards it tries to find a matching stackframe (skipping the first), but there is none. The loop to do so is a while loop, but the condition does not change, as
f
is not reassigned if the last frame is reached.There are two things to fix:
super().findCaller()
so it does not return itself rather than the intended function. (Maybe stacklevel)Alternativly do not set the global Logging class to RaspyLogger.