def MonkeyPatchThreadingLocal(_threading_local):

  @staticmethod
  def New(cls, *args, **kw):
    self = object.__new__(cls)
    key = '_local__key', 'thread.local.' + str(id(self))
    object.__setattr__(self, '_local__key', key)
    object.__setattr__(self, '_local__args', (args, kw))
    object.__setattr__(self, '_local__lock', _threading_local.RLock())
    if (args or kw) and (cls.__init__ is object.__init__):
      raise TypeError('Initialization arguments are not supported')
    dict = object.__getattribute__(self, '__dict__')
    _threading_local.current_thread().__dict__[key] = dict
    return self

  _threading_local._localbase.__new__ = New
Given a reference to the _threading_local module, fix _localbase.__new__.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/dev_appserver.py/MonkeyPatchThreadingLocal