model.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:t2-crash-reporter 作者: tessel 项目源码 文件源码
def add_or_remove(cls, fingerprint, crash, argv=None, labels=None, is_add=True, delta=1):
        # use an issue if one already exists
        issue = CrashReport.most_recent_issue(CrashReport.key_name(fingerprint))
        key_name = CrashReport.key_name(fingerprint)
        config = ShardedCounterConfig.get_sharded_config(key_name)
        shards = config.shards
        shard_to_use = random.randint(0, shards-1)
        shard_key_name = key_name + '_' + str(shard_to_use)
        if not argv:
            argv = []
        crash_report = CrashReport \
            .get_or_insert(shard_key_name,
                           name=key_name,
                           crash=crash,
                           fingerprint=fingerprint,
                           argv=argv,
                           labels=labels,
                           issue=issue)
        if is_add:
            crash_report.count += delta
            crash_report.put()
            # update caches
            memcache.incr(CrashReport.count_cache_key(key_name), delta, initial_value=0)
        else:
            crash_report.count -= delta
            crash_report.put()
            memcache.decr(CrashReport.count_cache_key(key_name), delta)

        # clear properties cache
        CrashReport.clear_properties_cache(key_name)
        return crash_report
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号