python类setrecursionlimit()的实例源码

bingrep_search.py 文件源码 项目:bingrep 作者: hada2 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def main(src_program, src_function, dst_program, f_silent, f_image, f_overwrite, f_top):
    sys.setrecursionlimit(3000)
    start_time = time.time()

    search_results = search_function(src_function, src_program, dst_program, f_top)
    if not search_results: return False
    else:
        (results, stats) = search_results

    result_time = time.time() - start_time
    stats["time"] = result_time

    if not f_silent:
        print_results(results, stats, src_program, src_function, dst_program)

        """
        if f_image:
            def image_dump(program, function, f_overwrite):
                function_short = get_short_function_name(function)

                if not f_overwrite:
                    if os.path.exists(os.path.join(get_dump_png_path(program), function_short + ".png")):
                        return

                flag = ["-o"] if f_overwrite else []
                cmd = ["python", "idascript.py", program, "bingrep_dump2.py", "-f", function, "-i"] + flag
                p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                p.communicate()

            print "Top 10 function images were dumped."
        """

    return (results, stats)
bingrep_dump.py 文件源码 项目:bingrep 作者: hada2 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def main(function, f_image, f_all, f_overwrite):

    sys.setrecursionlimit(3000)

    program = idaapi.get_root_filename()
    start_time = time.time()
    cfgs = get_cfgs()
    dump_function_info(cfgs, program, function, f_image, f_all, f_overwrite)
    result_time = time.time() - start_time

    print "Dump finished."
    print "result_time: " + str(result_time) + " sec."
tetris_theano.py 文件源码 项目:reinforcement_learning 作者: andreweskeclarke 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __copy_theano(self, theano_f):
        sys.setrecursionlimit(5000)
        pickle.dump(theano_f,
            open('/tmp/theano_model.p', 'wb'), 
            protocol=pickle.HIGHEST_PROTOCOL)
        copied_f = pickle.load(open('/tmp/theano_model.p', 'rb'))
        sys.setrecursionlimit(1000)
        return copied_f
testmock.py 文件源码 项目:RPoint 作者: george17-meet 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_copy(self):
        current = sys.getrecursionlimit()
        self.addCleanup(sys.setrecursionlimit, current)

        # can't use sys.maxint as this doesn't exist in Python 3
        sys.setrecursionlimit(int(10e8))
        # this segfaults without the fix in place
        copy.copy(Mock())
maze_gen.py 文件源码 项目:virtualnav-mpu6050 作者: amalrkrishna 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def main():
    sys.setrecursionlimit(N * N + 10)
    for i in range(N):
        visited.append([False] * N)
        maze.append([0] * N)
    depth_first_search(0, 0, 0)
    with open('maze_gen.out', 'w') as f:
        for row in maze:
            f.write(' '.join(map(str, row)))
            f.write('\n')
__init__.py 文件源码 项目:CSB 作者: csb-toolbox 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def serialize(self, file_name):
        """
        Serialize this HMM to a file.

        @param file_name: target file name
        @type file_name: str
        """
        rec = sys.getrecursionlimit()        
        sys.setrecursionlimit(10000)
        csb.io.Pickle.dump(self, open(file_name, 'wb'))
        sys.setrecursionlimit(rec)
__init__.py 文件源码 项目:CSB 作者: csb-toolbox 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def deserialize(file_name):
        """
        De-serialize an HMM from a file.

        @param file_name: source file name (pickle)
        @type file_name: str
        """
        rec = sys.getrecursionlimit()
        sys.setrecursionlimit(10000)
        try:
            return csb.io.Pickle.load(open(file_name, 'rb'))
        finally:
            sys.setrecursionlimit(rec)
model.py 文件源码 项目:yadll 作者: pchavanne 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def save_model(model, file=None):
    """
    Save the model to file with cPickle
    This function is used by the training function to save the model.
    Parameters
    ----------
    model : :class:`yadll.model.Model`
        model to be saved in file
    file : `string`
        file name

    """
    if file is None:
        if model.file is None:
            logger.error('No file name. Model not saved.')
            return
        else:
            d_file = model.file
    else:
        d_file = file

    try:
        with open(d_file, 'wb') as f:
            pickle.dump(model, f, pickle.HIGHEST_PROTOCOL)
    except RuntimeError:
        sys.setrecursionlimit(5000)
        with open(d_file, 'wb') as f:
            pickle.dump(model, f, pickle.HIGHEST_PROTOCOL)
common.py 文件源码 项目:service-notifications 作者: rehive 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def limited_recursion(recursion_limit):
    """
    Prevent unlimited recursion.
    """

    old_limit = sys.getrecursionlimit()
    sys.setrecursionlimit(recursion_limit)

    try:
        yield
    finally:
        sys.setrecursionlimit(old_limit)
nutszebra_utility.py 文件源码 项目:trainer 作者: nutszebra 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def set_recursion_limit(n=1 * 10 ** 8):
        sys.setrecursionlimit(n)
        return True
test_sys.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
knapsack.py 文件源码 项目:lovecollocdehyuki 作者: dpointin 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def solve(self):
        # increase recursion depth to avoid
        sys.setrecursionlimit(10000)
        for server in self.servers:
            logging.info("Server number " + str(server.id))
            self.knapsack_list = [ChoiceStructure(video, server) for video in self.videos]
            self.knapsack_iterative()
pdfcropper.py 文件源码 项目:krop 作者: gocarlos 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def writeToStream(self, stream):
        # For certain large pdf files, PdfFileWriter.write() causes the error:
        #  maximum recursion depth exceeded while calling a Python object
        # This issue is present in pyPdf as well as PyPDF2 1.23
        # We therefore temporarily increase the recursion limit.
        old_reclimit = sys.getrecursionlimit()
        sys.setrecursionlimit(10000)
        self.output.write(stream)
        sys.setrecursionlimit(old_reclimit)
trial.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def opt_recursionlimit(self, arg):
        """see sys.setrecursionlimit()"""
        try:
            sys.setrecursionlimit(int(arg))
        except (TypeError, ValueError):
            raise usage.UsageError(
                "argument to recursionlimit must be an integer")
test_idioms.py 文件源码 项目:cti-stix-elevator 作者: oasis-open 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def setup_tests():
    sys.setrecursionlimit(2000)
    directory = os.path.dirname(__file__)

    xml_idioms_dir = find_dir(directory, "idioms-xml")
    json_idioms_dir = find_dir(directory, "idioms-json")

    print("Setting up tests from following directories...")
    print(xml_idioms_dir)
    print(json_idioms_dir)

    for json_filename in sorted(os.listdir(json_idioms_dir)):
        if json_filename.endswith(".json"):
            path = os.path.join(json_idioms_dir, json_filename)

            json_file = open(path, "r")
            io = StringIO(json_file.read())
            loaded_json = json.load(io)
            json_file.close()

            MASTER_JSON_FILES.append(loaded_json)

    for xml_filename in sorted(os.listdir(xml_idioms_dir)):
        if xml_filename.endswith(".xml"):
            path = os.path.join(xml_idioms_dir, xml_filename)
            XML_FILENAMES.append(xml_filename.split(".")[0])
            TESTED_XML_FILES.append(path)
main.py 文件源码 项目:AlgorithmAnalysis 作者: davidfcalle 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def main():
    sys.setrecursionlimit(100000)
    #take_data( quick_sort_helper , "quick_sort-ordered.csv" , generate_ordered_vector )
    #take_data( quick_sort_helper , "quick_sort-unordered.csv" , generate_inverse_vector )
    take_data( quick_sort_helper , "quick_sort-mixed.csv" , generate_vector )
    #take_data( merge_sort_helper , "merge_sort-mixed.csv" , generate_vector )
    #take_data( merge_sort_helper , "merge_sort-ordered.csv" , generate_ordered_vector )
    #take_data( merge_sort_helper , "merge_sort-unordered.csv" , generate_inverse_vector )
    #take_data( insertion_sort , "insertion_sort-mixed.csv" , generate_vector )
    #take_data( insertion_sort , "insertion_sort-ordered.csv" , generate_ordered_vector )
    #take_data( insertion_sort , "insertion_sort-unordered.csv" , generate_inverse_vector )
testmock.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_copy(self):
        current = sys.getrecursionlimit()
        self.addCleanup(sys.setrecursionlimit, current)

        # can't use sys.maxint as this doesn't exist in Python 3
        sys.setrecursionlimit(int(10e8))
        # this segfaults without the fix in place
        copy.copy(Mock())
test_sys.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
driver_unit_test.py 文件源码 项目:cloudsdk-test-driver 作者: GoogleCloudPlatform 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def setUpClass(cls):
    # If there's an infinite recursion in the dictionary code, this will help
    # make the error messages more readable.
    cls._old_limit = sys.getrecursionlimit()
    sys.setrecursionlimit(100)
driver_unit_test.py 文件源码 项目:cloudsdk-test-driver 作者: GoogleCloudPlatform 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def tearDownClass(cls):
    # Put the recursion limit back where it was.
    sys.setrecursionlimit(cls._old_limit)


问题


面经


文章

微信
公众号

扫码关注公众号