[issue30441] os.environ raises RuntimeError: dictionary changed size during iteration

Osvaldo Santana Neto report at bugs.python.org
Tue May 23 12:29:06 EDT 2017


Osvaldo Santana Neto added the comment:

I agree with Jelle about the fix's implementation. But I disagree of suggestion to implement lock at the application side.

I disagree because some external libraries may want to access os.environ in a concurrent fashion without lock acquiring. That's the case reported in my previous comment: urllib/requests.py (https://github.com/python/cpython/blob/master/Lib/urllib/request.py#L2468) iterates over os.environ with no lock control.

How could I handle this issue in this case? Would it be a good idea  implement the lock mechanism in current os._Environ (https://github.com/python/cpython/blob/master/Lib/os.py#L666) mapping class?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30441>
_______________________________________


More information about the Python-bugs-list mailing list