Skip to content

Exceptions in stream generator are (somewhat) ignored #80

@nchidsey

Description

@nchidsey

Exceptions that occur inside a stream generator do not usually cause the program to stop. They are printed to stderr but then either continue or another unrelated exception is raised from rtree. Three reproduction examples:

def keyboard_interrupt_gen():
    while True:
        yield (0, (1,2,3,4), None)
        time.sleep(0.1)

def bad_gen_1():
    # insert at least 6 or so before the exception
    for i in range(10):
        yield (i, (1,2,3,4), None)
    raise Exception("raising here")

def bad_gen_2():
    yield (0, (1,2,3,4), None)
    raise Exception("raising here")

Rtree(keyboard_interrupt_gen())
print "should not get here"

If a KeyboardInterrupt or any other exception is raised after a minimal number of items are yielded (looks like around 5), then a traceback is printed to stderr, but the exception is lost and the code continues. "should not get here" is printed in the example above for the first two generator functions even though they never finish successfully.

If the exception occurs before a minimal number of items (but after at least 1), then the traceback is printed to stderr as above, but also another exception occurs in rtree, which at least ends the processing though not with the original exception:

rtree.core.RTreeError: Error in "Index_CreateWithStream": IllegalArgumentException: Region::combineRegion: Region has different number of dimensions.
Exception AttributeError: AttributeError("'IndexStreamHandle' object has no attribute '_ptr'",) in <bound method IndexStreamHandle.__del__ of <rtree.index.IndexStreamHandle object at 0x0229DEF0>> ignored

So under normal conditions, a KeyboardInterrupt or other exception is effectively ignored and the program continues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions