# Path: sider/threadlocal.py
# class LocalDict(collections.MutableMapping):
#     def __init__(self, mapping=[], **keywords):
#     def current(self):
#     def __len__(self):
#     def __iter__(self):
#     def __contains__(self, value):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def copy(self):
#     def get(self, key, default=None):
#     def has_key(self, key):
#     def items(self):
#     def iteritems(self):
#     def iterkeys(self):
#     def itervalues(self):
#     def keys(self):
#     def values(self):
#     def clear(self):
#     def pop(self, key, *args):
#     def popitem(self):
#     def setdefault(self, key, default=None):
#     def update(self, mapping, **keywords):


import threading
    import greenlet
from sider.threadlocal import LocalDict, get_ident
if greenlet:
    def coro_test(generator, args1=(), args2=()):
        def test(g, v, *args):
            cc, next_args = v
            next(g)
            for arg in args:
                try:
                    g.send(arg)
                except StopIteration:
                    break
                finally:
                    if cc is not None:
                        cc.switch(*next_args)
        c1 = greenlet.greenlet(test)
        c2 = greenlet.greenlet(test)
        c1.switch(generator(),
                  (c2, (generator(), (c1, ())) + args2),
                  *args1)
else:
    def coro_test(*a, **k):
        pass  # skip


def test_get_ident():
    result = [None, None]
    local = {}
    def run():
        value = yield
        local[get_ident()] = value
        result_idx = yield

# Path: sider/threadlocal.py
# class LocalDict(collections.MutableMapping):
#     def __init__(self, mapping=[], **keywords):
#     def current(self):
#     def __len__(self):
#     def __iter__(self):
#     def __contains__(self, value):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def copy(self):
#     def get(self, key, default=None):
#     def has_key(self, key):
#     def items(self):
#     def iteritems(self):
#     def iterkeys(self):
#     def itervalues(self):
#     def keys(self):
#     def values(self):
#     def clear(self):
#     def pop(self, key, *args):
#     def popitem(self):
#     def setdefault(self, key, default=None):
#     def update(self, mapping, **keywords):


# Path: sidertests/test_threadlocal.py
import threading
    import greenlet
from sider.threadlocal import LocalDict, get_ident

if greenlet:
    def coro_test(generator, args1=(), args2=()):
        def test(g, v, *args):
            cc, next_args = v
            next(g)
            for arg in args:
                try:
                    g.send(arg)
                except StopIteration:
                    break
                finally:
                    if cc is not None:
                        cc.switch(*next_args)
        c1 = greenlet.greenlet(test)
        c2 = greenlet.greenlet(test)
        c1.switch(generator(),
                  (c2, (generator(), (c1, ())) + args2),
                  *args1)
else:
    def coro_test(*a, **k):
        pass  # skip


def test_get_ident():
    result = [None, None]
    local = {}
    def run():
        value = yield
        local[get_ident()] = value
        result_idx = yield

        result[result_idx] = local.setdefault(get_ident())