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


Python sys.getrecursionlimit函数代码示例

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


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

示例1: test

def test():
    '''Test basic workings of `TempRecursionLimitSetter`.'''
    old_recursion_limit = sys.getrecursionlimit()
    assert sys.getrecursionlimit() == old_recursion_limit
    with TempRecursionLimitSetter(old_recursion_limit + 3):
        assert sys.getrecursionlimit() == old_recursion_limit + 3
    assert sys.getrecursionlimit() == old_recursion_limit
开发者ID:TobiasSimon,项目名称:GarlicSim,代码行数:7,代码来源:test_recursion_limit_setter.py

示例2: main

def main():
    lock = threading.Lock()
    with lock:
        t = threading.Thread(target=foo, args=(lock,))
        t.start()
        sys.getrecursionlimit()     # C function: sys_getrecursionlimit()
    t.join()
开发者ID:jimmysitu,项目名称:pyclewn,代码行数:7,代码来源:foo_thread.py

示例3: test_accessibility_on_very_deep_graph

def test_accessibility_on_very_deep_graph():
    gr = graph()
    gr.add_nodes(range(0,311)) # 2001
    for i in range(0,310): #2000
        gr.add_edge((i,i+1))
    recursionlimit = getrecursionlimit()
    accessibility(gr)
    assert getrecursionlimit() == recursionlimit
开发者ID:wdv4758h,项目名称:ZipPy,代码行数:8,代码来源:python-graph-bench.py

示例4: test_cut_edges_on_very_deep_graph

 def test_cut_edges_on_very_deep_graph(self):
     gr = pygraph.classes.graph.graph()
     gr.add_nodes(range(0,5001))
     for i in range(0,5000):
         gr.add_edge((i,i+1))
     recursionlimit = getrecursionlimit()
     cut_edges(gr)
     assert getrecursionlimit() == recursionlimit
开发者ID:GadgetSteve,项目名称:python-graph,代码行数:8,代码来源:unittests-accessibility.py

示例5: test_topological_sort_on_very_deep_graph

 def test_topological_sort_on_very_deep_graph(self):
     gr = pygraph.classes.graph.graph()
     gr.add_nodes(list(range(0,20001)))
     for i in range(0,20000):
         gr.add_edge((i,i+1))
     recursionlimit = getrecursionlimit()
     topological_sorting(gr)
     assert getrecursionlimit() == recursionlimit
开发者ID:soeltjen,项目名称:python-graph,代码行数:8,代码来源:unittests-sorting.py

示例6: test_dfs_very_deep_graph

 def test_dfs_very_deep_graph(self):
     gr = pygraph.classes.graph.graph()
     gr.add_nodes(range(0,20001))
     for i in range(0,20000):
         gr.add_edge((i,i+1))
     recursionlimit = getrecursionlimit()
     depth_first_search(gr, 0)
     assert getrecursionlimit() == recursionlimit
开发者ID:GadgetSteve,项目名称:python-graph,代码行数:8,代码来源:unittests-searching.py

示例7: test_recursionlimit

 def test_recursionlimit(self):
     self.assertRaises(TypeError, sys.getrecursionlimit, 42)
     oldlimit = sys.getrecursionlimit()
     self.assertRaises(TypeError, sys.setrecursionlimit)
     self.assertRaises(ValueError, sys.setrecursionlimit, -42)
     sys.setrecursionlimit(10000)
     self.assertEqual(sys.getrecursionlimit(), 10000)
     sys.setrecursionlimit(oldlimit)
开发者ID:MaximVanyushkin,项目名称:Sharp.RemoteQueryable,代码行数:8,代码来源:test_sys.py

示例8: test_accessibility_on_very_deep_graph

 def test_accessibility_on_very_deep_graph(self):
     gr = pygraph.classes.graph.graph()
     gr.add_nodes(range(0,2001))
     for i in range(0,2000):
         gr.add_edge((i,i+1))
     recursionlimit = getrecursionlimit()
     accessibility(gr)
     assert getrecursionlimit() == recursionlimit
开发者ID:GadgetSteve,项目名称:python-graph,代码行数:8,代码来源:unittests-accessibility.py

示例9: test_recursionlimit

 def test_recursionlimit(self):
     import sys
     raises(TypeError, sys.getrecursionlimit, 42)
     oldlimit = sys.getrecursionlimit()
     raises(TypeError, sys.setrecursionlimit)
     raises(ValueError, sys.setrecursionlimit, -42)
     sys.setrecursionlimit(10000)
     assert sys.getrecursionlimit() == 10000
     sys.setrecursionlimit(oldlimit)
     raises(OverflowError, sys.setrecursionlimit, 1<<31)
开发者ID:yuyichao,项目名称:pypy,代码行数:10,代码来源:test_sysmodule.py

示例10: test_as_decorator

def test_as_decorator():
    '''Test `TempRecursionLimitSetter` when used as a decorator.'''
    old_recursion_limit = sys.getrecursionlimit()
    @TempRecursionLimitSetter(1234)
    def f():
        assert sys.getrecursionlimit() == 1234
    assert sys.getrecursionlimit() == old_recursion_limit
    f()
    assert sys.getrecursionlimit() == old_recursion_limit
    
    cute_testing.assert_polite_wrapper(f)
开发者ID:TobiasSimon,项目名称:GarlicSim,代码行数:11,代码来源:test_recursion_limit_setter.py

示例11: test_standardOptions

 def test_standardOptions(self):
     """
     L{WorkerOptions} supports a subset of standard options supported by
     trial.
     """
     self.addCleanup(sys.setrecursionlimit, sys.getrecursionlimit())
     if gc.isenabled():
         self.addCleanup(gc.enable)
     gc.enable()
     self.options.parseOptions(["--recursionlimit", "2000", "--disablegc"])
     self.assertEqual(2000, sys.getrecursionlimit())
     self.assertFalse(gc.isenabled())
开发者ID:ssilverek,项目名称:kodb,代码行数:12,代码来源:test_options.py

示例12: Save

def Save(session, filename=None):
    """
    save your session to use it later.

    Returns the filename of the written file.
    If not filename is given, a file named `androguard_session_<DATE>.ag` will
    be created in the current working directory.
    `<DATE>` is a timestamp with the following format: `%Y-%m-%d_%H%M%S`.

    This function will overwrite existing files without asking.

    If the file could not written, None is returned.

    example::

        s = session.Session()
        session.Save(s, "msession.ag")

    :param session: A Session object to save
    :param filename: output filename to save the session
    :type filename: string

    """

    if not filename:
        filename = "androguard_session_{:%Y-%m-%d_%H%M%S}.ag".format(datetime.datetime.now())

    if os.path.isfile(filename):
        log.warning("{} already exists, overwriting!")

    # Setting the recursion limit according to the documentation:
    # https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled
    #
    # Some larger APKs require a high recursion limit.
    # Tested to be above 35000 for some files, setting to 50k to be sure.
    # You might want to set this even higher if you encounter problems
    reclimit = sys.getrecursionlimit()
    sys.setrecursionlimit(50000)
    saved = False
    try:
        with open(filename, "wb") as fd:
            pickle.dump(session, fd)
        saved = True
    except RecursionError:
        log.exception("Recursion Limit hit while saving. "
                      "Current Recursion limit: {}. "
                      "Please report this error!".format(sys.getrecursionlimit()))
        # Remove partially written file
        os.unlink(filename)

    sys.setrecursionlimit(reclimit)
    return filename if saved else None
开发者ID:androguard,项目名称:androguard,代码行数:52,代码来源:session.py

示例13: calculate_acc_index

def calculate_acc_index(dir_arr, origin_upper_left=True):

    # modify maximum recursion depth if required
    import sys
    rec_depth = sys.getrecursionlimit()
    sys.setrecursionlimit(max(dir_arr.shape[0] * dir_arr.shape[1], rec_depth))



    acc_index = np.ones(dir_arr.shape)
    cache = -np.ones(dir_arr.shape)




    n1, n2 = acc_index.shape

    for i in range(n1):
        if i % 100 == 0:
            print("{}/{} ...".format(i, n1))

        for j in range(n2):
            acc_index[i, j] = calculate_acc_index_for_point(i, j, dir_arr, cache, origin_upper_left=origin_upper_left)

    # print(acc_index.min(), acc_index.max())

    return acc_index
开发者ID:guziy,项目名称:RPN,代码行数:27,代码来源:reverse_river_in_hydrosheds_nc.py

示例14: main

def main():
    max_recursion = sys.getrecursionlimit() / 4
    if len(sys.argv) < 2:
        n = 250
    else:
        n = int(sys.argv[1])

    print n / max_recursion
    for i in range(n / max_recursion):
        c = (i+1)*max_recursion
        # print i, c
        f(c)
        catalan(c)
    print_fac(n)

    n = 100
    for i in range(n / max_recursion):
        c = (i+1)*max_recursion
        catalan(c)
    for i in range(n):
        print(catalan(i))
    print catalan(n)
    print "="*20
    for i in range(30):
        print i, ci(i)
开发者ID:edilio,项目名称:Memoizer,代码行数:25,代码来源:play.py

示例15: tag_molecules

def tag_molecules(struct):
    """
    Sets the ``marked`` attribute of every Atom in struct to the molecule number
    it is a part of. If no bonds are present, every atom is its own molecule.

    Parameters
    ----------
    struct : :class:`parmed.Structure`
        Input structure to tag the molecules for
    """
    # Make sure our recursion limit is large enough, but never shrink it
    from sys import setrecursionlimit, getrecursionlimit
    setrecursionlimit(max(len(struct.atoms), getrecursionlimit()))

    if not struct.bonds:
        for i, atom in enumerate(struct.atoms):
            atom.marked = i + 1
        return
    # We do have bonds, this is the interesting part
    struct.atoms.unmark()
    mol_id = 1
    for atom in struct.atoms:
        if atom.marked: continue
        atom.marked = mol_id
        _set_owner(atom, mol_id)
        mol_id += 1
开发者ID:jchodera,项目名称:ParmEd,代码行数:26,代码来源:__init__.py


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