This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author osantana
Recipients osantana
Date 2017-05-23.14:35:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
We're facing ocasional RuntimeError exceptions in a multithreaded application when one of the threads creates new entries to the environment (os.environ).

I'm not so sure if the attached patch fixes this issue the right way, so, feel free to propose another approach.

Traceback Sample of the issue in our production environment:

RuntimeError: dictionary changed size during iteration
  File "python3.5/", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "python3.5/", line 85, in _run_code
    exec(code, run_globals)

  [ internal code ]

  File "newrelic/api/", line 103, in wrapper
    return wrapped(*args, **kwargs)
  File "python3.5/", line 30, in inner
    return func(*args, **kwds)
  File "python3.5/", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "raven/", line 851, in make_decorator
  File "python3.5/", line 30, in inner
    return func(*args, **kwds)

  [ internal code ]

  File "retry/", line 74, in retry_decorator
  File "retry/", line 33, in __retry_internal
    return f()

  [ internal code ]

  File "requests/", line 531, in get
    return self.request('GET', url, **kwargs)
  File "requests/", line 509, in request
    prep.url, proxies, stream, verify, cert
  File "requests/", line 686, in merge_environment_settings
    env_proxies = get_environ_proxies(url, no_proxy=no_proxy)
  File "requests/", line 696, in get_environ_proxies
    return getproxies()
  File "urllib/", line 2393, in getproxies_environment
    for name, value in os.environ.items():
  File "", line 676, in __iter__
    for key in self._mapping:
  File "python3.5/", line 702, in __iter__
    for key in self._data:
Date User Action Args
2017-05-23 14:35:51osantanasetrecipients: + osantana
2017-05-23 14:35:50osantanasetmessageid: <>
2017-05-23 14:35:50osantanalinkissue30441 messages
2017-05-23 14:35:50osantanacreate