title: how to use gevent local module
body: <p>I'm trying to use gevent.local module to have a greenlet context.
  Following the example in: <a href="http://www.gevent.org/gevent.local.html" rel="nofollow noreferrer">http://www.gevent.org/gevent.local.html</a>
  I tried this sample code:</p>
  
  <pre><code>#!env python
  
  import gevent
  from gevent import local
  
  def foo():
      print("IN FOO")
      data = local.local()
      data.numbers = 42
  
      bar()
  
  def bar():
      print("IN BAR")
      data = local.local()
      print(data.numbers)
  
  
  def main():
      foo_gl = gevent.Greenlet(foo)
      print("starting foo")
      foo_gl.start()
      gevent.joinall([foo_gl])
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>But I get an error:</p>
  
  <pre><code>$ mytest/local.py
  starting foo
  IN FOO
  IN BAR
  Traceback (most recent call last):
    File "/Users/me/.virtualenvs/sorites/lib/python2.7/site-packages/gevent/greenlet.py", line 327, in run
      result = self._run(*self.args, **self.kwargs)
    File "gl_test/local.py", line 11, in foo
      bar()
    File "gl_test/local.py", line 16, in bar
      print(data.numbers)
    File "/Users/me/.virtualenvs/sorites/lib/python2.7/site-packages/gevent/local.py", line 186, in __getattribute__
      return object.__getattribute__(self, name)
  AttributeError: 'local' object has no attribute 'numbers'
  &lt;Greenlet at 0x1053b2410: foo&gt; failed with AttributeError
  </code></pre>
  
  <p>What am I missing here? Thanks!</p>