root/galaxy-central/eggs/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/util/threadinglocal.py

リビジョン 3, 1.3 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
2# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
3
4try:
5    import threading
6except ImportError:
7    # No threads, so "thread local" means process-global
8    class local(object):
9        pass
10else:
11    try:
12        local = threading.local
13    except AttributeError:
14        # Added in 2.4, but now we'll have to define it ourselves
15        import thread
16        class local(object):
17
18            def __init__(self):
19                self.__dict__['__objs'] = {}
20
21            def __getattr__(self, attr, g=thread.get_ident):
22                try:
23                    return self.__dict__['__objs'][g()][attr]
24                except KeyError:
25                    raise AttributeError(
26                        "No variable %s defined for the thread %s"
27                        % (attr, g()))
28
29            def __setattr__(self, attr, value, g=thread.get_ident):
30                self.__dict__['__objs'].setdefault(g(), {})[attr] = value
31
32            def __delattr__(self, attr, g=thread.get_ident):
33                try:
34                    del self.__dict__['__objs'][g()][attr]
35                except KeyError:
36                    raise AttributeError(
37                        "No variable %s defined for thread %s"
38                        % (attr, g()))
39
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。