本文整理汇总了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
示例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()
示例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
示例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
示例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
示例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
示例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)
示例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
示例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)
示例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)
示例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())
示例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
示例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
示例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)
示例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