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

ROSBagException should call the base constructor #1209

@lukehansen

Description

@lukehansen

In python 2.7 there is a subtle bug with unpickling custom exceptions; this was fixed in 3.3, see https://bugs.python.org/issue1692335. As a workaround for 2.7 we can re-define these exceptions as below.

class ROSBagException(Exception):
    """
    Base class for exceptions in rosbag.
    """
    pass
 
class ROSBagFormatException(ROSBagException):
    """
    Exceptions for errors relating to the bag file format.
    """
    pass

class ROSBagUnindexedException(ROSBagException):
    """
    Exception for unindexed bags.
    """
    def __init__(self, *args):
        ROSBagException.__init__(self, 'Unindexed bag')

For context, I came across this issue when a ROSBagUnindexedException was raised in a multiprocessing.Pool.map thread. It throws the __init__ exception and hangs, as described here: https://lists.gt.net/python/bugs/1025933

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions