当前位置: 首页>>代码示例>>Python>>正文


Python threading.lock函数代码示例

本文整理汇总了Python中threading.lock函数的典型用法代码示例。如果您正苦于以下问题:Python lock函数的具体用法?Python lock怎么用?Python lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了lock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete_neighbor

 def delete_neighbor(self, key, neighbor):
     with lock():
         for p in self.peer['prefixes']:
             if p['prefix'] == key and p['next_hop'] == neighbor:
                 self.peer['prefix'].remove(p)
                 self.db['peers'].save(self.peer)
                 break
开发者ID:rafaelsilvag,项目名称:routeops,代码行数:7,代码来源:rib.py

示例2: get_prefixes

 def get_prefixes(self, key):
     with lock():
         result = []
         for p in self.peer['prefixes']:
             if p['prefix'] == key:
                 result.append(p)
         return result
开发者ID:rafaelsilvag,项目名称:routeops,代码行数:7,代码来源:rib.py

示例3: delete

 def delete(self, key):
     with lock():
         for p in self.peer['prefixes']:
             if p['prefix'] == key:
                 self.peer['prefixes'].remove(p)
                 self.db['peers'].save(self.peer)
                 break
开发者ID:rafaelsilvag,项目名称:routeops,代码行数:7,代码来源:rib.py

示例4: get

 def get(self,key): 
     
     with lock():
         cursor = self.db.cursor()
         cursor.execute('''select * from ''' + self.name + ''' where prefix = ?''', (key,))
     
         return cursor.fetchone()
开发者ID:rbirkner,项目名称:sdx-ryu,代码行数:7,代码来源:rib.py

示例5: update

 def update(self,key,item,value):
     
     with lock():
         cursor = self.db.cursor()
     
         script = "update " + self.name + " set " + item + " = '" + value + "' where prefix = '" + key + "'"
     
         cursor.execute(script)
开发者ID:rbirkner,项目名称:sdx-ryu,代码行数:8,代码来源:rib.py

示例6: add_many

 def add_many(self,items):
     
     with lock():
         cursor = self.db.cursor()
     
         if (isinstance(items,list)):
             cursor.execute('''insert or replace into ''' + self.name + ''' (prefix, next_hop, origin, as_path, communities, med,
                     atomic_aggregate) values(?,?,?,?,?,?,?)''', items)
开发者ID:rbirkner,项目名称:sdx-ryu,代码行数:8,代码来源:rib.py

示例7: delete

 def delete(self,key):
     
     with lock():
         # TODO: Add more granularity in the delete process i.e., instead of just prefix, 
         # it should be based on a conjunction of other attributes too.
     
         cursor = self.db.cursor()
     
         cursor.execute('''delete from ''' + self.name + ''' where prefix = ?''', (key,))
开发者ID:rbirkner,项目名称:sdx-ryu,代码行数:9,代码来源:rib.py

示例8: update_neighbor

 def update_neighbor(self, key, item):
     with lock():
         if (isinstance(item, dict)):
             for p in self.peer['prefixes']:
                 if p['prefix'] == key and p['next_hop'] == item['next_hop']:
                     self.peer['prefixes'].remove(p)
                     break
             item['prefix'] = key
             self.peer['prefixes'].append(item)
             self.db['peers'].save(self.peer)
开发者ID:rafaelsilvag,项目名称:routeops,代码行数:10,代码来源:rib.py

示例9: filter

 def filter(self,item,value): 
         
     with lock():
         cursor = self.db.cursor()
     
         script = "select * from " + self.name + " where " + item + " = '" + value + "'"
     
         cursor.execute(script)
     
         return cursor.fetchall()
开发者ID:rbirkner,项目名称:sdx-ryu,代码行数:10,代码来源:rib.py

示例10: __init__

    def __init__(self, import_name, static_url_path=none,
                 static_folder='static', template_folder='templates',
                 instance_path=none, instance_relative_config=false):
        _packageboundobject.__init__(self, import_name,
                                     template_folder=template_folder)
        
        if static_url_path is not none:
            self.static_url_path = static_url_path
        if static_folder is not none:
            self.static_folder = static_folder
        if instance_path is none:
            instance_path = self.auto_find_instance_path()
        elif not os.path.isabs(instance_path):
            raise valueerror('if an instance path is provided it must be '
                             'absolute.  a relative path was given instead.')
        
        self.instance_path = instance_path
        
        self.config = self.make_config(instance_relative_config)
        
        self._logger = none
        self.logger_name = self.import_name

        self.view_functions = {}

        self.error_handler_spec = {none: self._error_handlers}

        self.url_build_error_handlers = []

        self.before_request_funcs = {}
        self.before_first_request_funcs = []
        self.after_request_funcs = {}
        self.teardown_request_funcs = {}
        self.teardown_appcontext_funcs = []
        
        self.url_value_preprocessors = {}
        self.url_default_functions = {}

        self.template_context_processors = {
            none: [_default_template_ctx_processor]
        }

        self.blueprints = {}

        self.extensions = {}

        self.url_map = map()

        self._got_first_request = false
        self._before_request_lock = lock()

        if self.has_static_folder:
            self.add_url_rule(self.static_url_path + '/<path:filename>',
                              endpoint='static',
                              view_func=self.send_static_file)
开发者ID:echhost,项目名称:flasker,代码行数:55,代码来源:app.py

示例11: update

 def update(self, item, value):
     with lock():
         if not self.peer['prefixes']:
             self.peer['prefixes'] = []
         for p in self.peer['prefixes']:
             if p['prefix'] == item:
                 self.peer['prefixes'].remove(p)
                 break
         value['prefix'] = item
         self.peer['prefixes'].append(value)
         self.db['peers'].save(self.peer)
开发者ID:rafaelsilvag,项目名称:routeops,代码行数:11,代码来源:rib.py

示例12: get_all

 def get_all(self,key=None): 
     
     with lock():    
         cursor = self.db.cursor()
     
         if (key is not None):
             cursor.execute('''select * from ''' + self.name + ''' where prefix = ?''', (key,))
         else:
             cursor.execute('''select * from ''' + self.name)
     
         return cursor.fetchall()
开发者ID:rbirkner,项目名称:sdx-ryu,代码行数:11,代码来源:rib.py

示例13: add

 def add(self, key, item):
     with lock():
         if not self.peer['prefixes']:
             self.peer['prefixes'] = []
         if (isinstance(item, dict)):
             for p in self.peer['prefixes']:
                 if p['prefix'] == key:
                     self.peer['prefixes'].remove(p)
                     break
             item['prefix'] = key
             self.peer['prefixes'].append(item)
             self.db['peers'].save(self.peer)
开发者ID:rafaelsilvag,项目名称:routeops,代码行数:12,代码来源:rib.py

示例14: add

 def add(self,key,item):
     
     with lock():
         cursor = self.db.cursor()
     
         if (isinstance(item,tuple) or isinstance(item,list)):
             cursor.execute('''insert or replace into ''' + self.name + ''' (prefix, next_hop, origin, as_path, communities, med,
                     atomic_aggregate) values(?,?,?,?,?,?,?)''', 
                     (key,item[0],item[1],item[2],item[3],item[4],item[5]))
         elif (isinstance(item,dict) or isinstance(item,sqlite3.Row)):
             cursor.execute('''insert or replace into ''' + self.name + ''' (prefix, next_hop, origin, as_path, communities, med,
                     atomic_aggregate) values(?,?,?,?,?,?,?)''', 
                     (key,item['next_hop'],item['origin'],item['as_path'],item['communities'],item['med'],item['atomic_aggregate']))
开发者ID:rbirkner,项目名称:sdx-ryu,代码行数:13,代码来源:rib.py

示例15: update_many

 def update_many(self,key,item):
     
     with lock():
         cursor = self.db.cursor()
     
         if (isinstance(item,tuple) or isinstance(item,list)):
             cursor.execute('''update ''' + self.name + ''' set next_hop = ?, origin = ?, as_path = ?,
                         communities = ?, med = ?, atomic_aggregate = ? where prefix = ?''',
                         (item[0],item[1],item[2],item[3],item[4],item[5],key))
         elif (isinstance(item,dict) or isinstance(item,sqlite3.Row)):
             cursor.execute('''update ''' + self.name + ''' set next_hop = ?, origin = ?, as_path = ?,
                         communities = ?, med = ?, atomic_aggregate = ? where prefix = ?''', 
                         (item['next_hop'],item['origin'],item['as_path'],item['communities'],item['med'],
                          item['atomic_aggregate'],key))
开发者ID:rbirkner,项目名称:sdx-ryu,代码行数:14,代码来源:rib.py


注:本文中的threading.lock函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。