# Runtime Error when multi threading

**URL:** <https://ask.openrouteservice.org/t/runtime-error-when-multi-threading/592>\
**Category:** python\
**Created:** [May 31, 2019, 7:07am UTC](https://ask.openrouteservice.org/t/runtime-error-when-multi-threading/592 "2019-05-31T07:07:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pablopardoz](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/p/97f17d/32.png) [@pablopardoz](https://ask.openrouteservice.org/u/pablopardoz)\
**Post date:** [May 31, 2019, 7:07am UTC](https://ask.openrouteservice.org/t/runtime-error-when-multi-threading/592/1 "2019-05-31T07:07:58Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)\
**Post date:** [May 31, 2019, 8:51am UTC](https://ask.openrouteservice.org/t/runtime-error-when-multi-threading/592/2 "2019-05-31T08:51:47Z")

</div>

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;)

> <https://github.com/GIScience/openrouteservice-py/blob/master/CHANGELOG>

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

---

<div class="post-metadata">

**Author:** ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)\
**Post date:** [May 31, 2019, 12:05pm UTC](https://ask.openrouteservice.org/t/runtime-error-when-multi-threading/592/3 "2019-05-31T12:05:41Z")

</div>

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