Skip to content

parsing fails when running in a thread #90

Closed
@mjmottram

Description

@mjmottram

Hi,

I'm not sure whether this is a known issue, but if I run pyosmium parsing in a thread then the process hangs indefinitely. For example:

import sys
import threading

import osmium

function_complete = threading.Event()


def run_parsing(filename):
    print("Parsing %s ..." % filename)
    h = osmium.SimpleHandler()
    h.apply_file(filename)
    print("Parsed %s" % filename)
    function_complete.set()


if __name__ == "__main__":
    test_file = sys.argv[1]

    run_parsing(test_file)

    function_complete.clear()
    threading.Thread(target=run_parsing, args=(test_file,))
    function_complete.wait(timeout=10)

    if not function_complete.is_set():
        raise RuntimeError("parsing did not complete")

will parse when in the main thread, then raise as the threaded parsing never completes. Is this behaviour understood?

I'm running this on macOS in python 2.7.

Thanks!

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