Runtime Error when multi threading


#1

Hi.
I’m using the Python library for ORS directions, and sometimes I’m getting some errors (maybe 1 of each 100 queries thrown)

File "python3.5/site-packages/openrouteservice/validator.py", line 683, in _directions_validation
    v.validate(params, schema)
    File "python3.5/site-packages/cerberus/validator.py", line 992, in validate
    for field in self.document:
RuntimeError: dictionary changed size during iteration

File "python3.5/site-packages/openrouteservice/validator.py", line 683, in _directions_validation
    v.validate(params, schema)
File python3.5/site-packages/cerberus/validator.py", line 1044, in __validate_definitions
    value = self.document[field]
KeyError: 'geometry_format'

File "python3.5/site-packages/openrouteservice/validator.py", line 683, in _directions_validation
    v.validate(params, schema)
File python3.5/site-packages/cerberus/validator.py", line 1044, in __validate_definitions
    value = self.document[field]
KeyError: 'format_out'

File "python3.5/site-packages/openrouteservice/validator.py", line 683, in _directions_validation
    v.validate(params, schema)
File "python3.5/site-packages/cerberus/validator.py", line 992, in validate
    for field in self.document:
RuntimeError: dictionary changed size during iteration

As I’ve seen all of them comes from cerberus/validator.py, and the query I throw is always the same. This error comes when I throw some queries with threads.

Any clue on what could be happening?

thanks!


#2

Hi,

thanks for the report. You could even have filed an issue in Github, since this really looks like one.

Yeah, I guess the validator implementation wasn’t thread-safe. But I did remove a few days (or weeks) ago, as this whole object validation business is a pain in the *** and not worth the trouble;)

Please do make sure to use > v2.2.0. pip list will show you what you’re currently using.


#3

BTW, even with the version you’re using, each method accepts a validate=False, which won’t perform any cerberus validation.