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


Python DbContainer.close_thread_sql方法代码示例

本文整理汇总了Python中pyasm.search.DbContainer.close_thread_sql方法的典型用法代码示例。如果您正苦于以下问题:Python DbContainer.close_thread_sql方法的具体用法?Python DbContainer.close_thread_sql怎么用?Python DbContainer.close_thread_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.search.DbContainer的用法示例。


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

示例1: execute

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_thread_sql [as 别名]
 def execute(self):
     try:
         #Batch()
         #Command.execute_cmd(timed_trigger)
         Project.set_project(self.project_code)
         timed_triggers[self.index].execute()
     except Exception as e:
         raise
     finally:
         DbContainer.close_thread_sql()
         DbContainer.commit_thread_sql()
         DbContainer.close_all()
开发者ID:mincau,项目名称:TACTIC,代码行数:14,代码来源:monitor.py

示例2: execute

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_thread_sql [as 别名]
    def execute(my):

        import atexit
        import time
        atexit.register( my.cleanup )
        while 1:
            
            my.check_existing_jobs()
            my.check_new_job()
            time.sleep(my.check_interval)
            DbContainer.close_thread_sql()

            if my.max_jobs_completed != -1 and my.jobs_completed > my.max_jobs_completed:
                Common.restart()
                while 1:
                    print "Waiting to restart..."
                    time.sleep(1)
开发者ID:hellios78,项目名称:TACTIC,代码行数:19,代码来源:queue.py

示例3: execute

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_thread_sql [as 别名]
    def execute(self):

        import atexit
        import time
        atexit.register( self.cleanup )
        while 1:
            
            self.check_existing_jobs()
            self.check_new_job()
            time.sleep(self.check_interval)
            DbContainer.close_thread_sql()

            if self.max_jobs_completed != -1 and self.jobs_completed > self.max_jobs_completed:
                Common.restart()
                while 1:
                    print("Waiting to restart...")
                    time.sleep(1)
开发者ID:mincau,项目名称:TACTIC,代码行数:19,代码来源:queue.py

示例4: _execute

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_thread_sql [as 别名]

#.........这里部分代码省略.........
            for i in range(0, num_processes):
                job_thread = ASyncThread()
                job_thread.start()
                tactic_threads.append(job_thread)


        # Job Queue services
        if start_job_queue:
            num_processes = Config.get_value("services", "queue_process_count")
            if not num_processes:
                num_processes = 1
            else:
                num_processes = int(num_processes)

            for i in range(0, num_processes):
                job_thread = JobQueueThread(i)
                job_thread.start()
                tactic_threads.append(job_thread)


        # Watch Folder services
        if start_watch_folder:
            search = Search("sthpw/watch_folder")
            watch_folders = search.get_sobjects()

            for watch_folder in watch_folders:
                project_code = watch_folder.get("project_code")
                base_dir = watch_folder.get("base_dir")
                search_type = watch_folder.get("search_type")
                process = watch_folder.get("process")
                script_path = watch_folder.get("script_path")
                watch_folder_code = watch_folder.get("code")

                if not project_code:
                    print("Watch Folder missing project_code ... skipping")
                    continue

                if not base_dir:
                    print("Watch Folder missing base_dir ... skipping")
                    continue

                if not search_type:
                    print("Watch Folder missing search_type ... skipping")
                    continue

                self.watch_folder_cleanup(base_dir)

                watch_thread = WatchFolderThread(
                        project_code=project_code,
                        base_dir=base_dir,
                        search_type=search_type,
                        process=process,
                        script_path = script_path,
                        watch_folder_code=watch_folder_code
                )
                watch_thread.start()
                tactic_threads.append(watch_thread)



        # set up custom services 
        for service in custom_services:
            kwargs = Config.get_section_values(service)
            custom_thread = CustomPythonProcessThread(**kwargs)
            custom_thread.start()
            tactic_threads.append(custom_thread)



        if len(tactic_threads) == 0:
            print("\n")
            print("No services started ...")
            print("\n")
            return



        # create a separate thread for timed processes
        # DEPRECATED
        tactic_timed_thread = TacticTimedThread()
        tactic_timed_thread.start()
        tactic_threads.append(tactic_timed_thread)

        # create a separate thread for scheduler processes

        start_scheduler = Config.get_value("services", "scheduler")
        if start_scheduler == 'true' or True:
            tactic_scheduler_thread = TacticSchedulerThread()
            tactic_scheduler_thread.set_dev(self.dev_mode)
            tactic_scheduler_thread.start()
            tactic_threads.append(tactic_scheduler_thread)





        DbContainer.close_thread_sql()
        self.tactic_threads = tactic_threads
        if self.mode == "normal":
            self.monitor()
开发者ID:mincau,项目名称:TACTIC,代码行数:104,代码来源:monitor.py

示例5: run

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_thread_sql [as 别名]
 def run(self):
     try:
         Batch()
         timed_trigger._do_execute()
     finally:
         DbContainer.close_thread_sql()
开发者ID:mincau,项目名称:TACTIC,代码行数:8,代码来源:monitor.py

示例6: execute

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_thread_sql [as 别名]
    def execute(my):
        from pyasm.security import Batch
        Batch(login_code="admin")

        os.environ["TACTIC_MONITOR"] = "true"

        if not my.num_processes:
            my.num_processes = Config.get_value("services", "process_count")
            if my.num_processes:
                my.num_processes = int(my.num_processes)
            else:
                my.num_processes = 3


        start_port = Config.get_value("services", "start_port")

        ports_str = os.environ.get("TACTIC_PORTS")
        if not ports_str:
            ports_str = Config.get_value("services", "ports")

        if ports_str:
            ports = ports_str.split("|")
            ports = [int(x) for x in ports]
        else:
            if start_port:
                start_port = int(start_port)
            else:
                start_port = 8081
            ports = []
            for i in range(0, my.num_processes):
                ports.append( start_port + i )
                

        tactic_threads = []

        # create a number of processes
        use_tactic = Config.get_value("services", "tactic")
        if use_tactic != 'false':
            #for i in range(0, my.num_processes):
            for port in ports:

                # start cherrypy
                tactic_thread = TacticThread(port)
                tactic_thread.set_dev(my.dev_mode)

                tactic_thread.start()
                tactic_threads.append(tactic_thread)
                time.sleep(1)
                #port += 1


        # Job Queue services
        use_job_queue = Config.get_value("services", "job_queue")
        if use_job_queue == 'true':
            num_processes = Config.get_value("services", "queue_process_count")
            if not num_processes:
                num_processes = 1
            else:
                num_processes = int(num_processes)

            for i in range(0, num_processes):
                job_thread = JobQueueThread()
                job_thread.start()
                tactic_threads.append(job_thread)



        # create a separate thread for timed processes
        # DEPRECATED
        tactic_timed_thread = TacticTimedThread()
        tactic_timed_thread.start()
        tactic_threads.append(tactic_timed_thread)

        # create a separate thread for scheduler processes

        use_scheduler = Config.get_value("services", "scheduler")
        if use_scheduler == 'true':
            tactic_scheduler_thread = TacticSchedulerThread()
            tactic_scheduler_thread.start()
            tactic_threads.append(tactic_scheduler_thread)





        DbContainer.close_thread_sql()


        # check each thread every 20 seconds
        while 1:
            end = False
            try:
                if my.check_interval:
                    time.sleep(my.check_interval)
                    for tactic_thread in tactic_threads:
                        tactic_thread._check()

                else:
                    # FIXME: break for now (for windows service)
                    break
#.........这里部分代码省略.........
开发者ID:funic,项目名称:TACTIC,代码行数:103,代码来源:monitor.py

示例7: __init__

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_thread_sql [as 别名]
            def __init__(my, **kwargs):
                super(TimedTask, my).__init__(**kwargs)
                my.index = kwargs.get("index")
                my.project_code = kwargs.get("project_code")

            def execute(my):
                try:
                    #Batch()
                    #Command.execute_cmd(timed_trigger)
                    Project.set_project(my.project_code)
                    timed_triggers[my.index].execute()
                except Exception, e:
                    print "Error running trigger"
                    raise
                finally:
                    DbContainer.close_thread_sql()
                    DbContainer.commit_thread_sql()
                    DbContainer.close_all()


        for idx, timed_trigger in enumerate(timed_triggers):

            data = timed_trigger.get_input()
            if not data:
                continue

            """
            data = {
                'type': 'interval',
                'interval': 10,
                'delay': 0,
开发者ID:funic,项目名称:TACTIC,代码行数:33,代码来源:monitor.py

示例8: execute

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_thread_sql [as 别名]

#.........这里部分代码省略.........

            for i in range(0, num_processes):
                job_thread = JobQueueThread()
                job_thread.start()
                tactic_threads.append(job_thread)


        # Watch Folder services
        if start_watch_folder:
            search = Search("sthpw/watch_folder")
            watch_folders = search.get_sobjects()

            for watch_folder in watch_folders:
                project_code = watch_folder.get("project_code")
                base_dir = watch_folder.get("base_dir")
                search_type = watch_folder.get("search_type")
                process = watch_folder.get("process")

                if not project_code:
                    print "Watch Folder missing project_code ... skipping"
                    continue

                if not project_code:
                    print "Watch Folder missing base_dir ... skipping"
                    continue

                if not search_type:
                    print "Watch Folder missing search_type ... skipping"
                    continue

                watch_thread = WatchFolderThread(
                        project_code=project_code,
                        base_dir=base_dir,
                        search_type=search_type,
                        process=process
                        )
                watch_thread.start()
                tactic_threads.append(watch_thread)



        # set up custom services 
        for service in custom_services:
            kwargs = Config.get_section_values(service)
            custom_thread = CustomPythonProcessThread(**kwargs)
            custom_thread.start()
            tactic_threads.append(custom_thread)



        if len(tactic_threads) == 0:
            print
            print "No services started ..."
            print
            return



        # create a separate thread for timed processes
        # DEPRECATED
        tactic_timed_thread = TacticTimedThread()
        tactic_timed_thread.start()
        tactic_threads.append(tactic_timed_thread)

        # create a separate thread for scheduler processes

        start_scheduler = Config.get_value("services", "scheduler")
        if start_scheduler == 'true':
            tactic_scheduler_thread = TacticSchedulerThread()
            tactic_scheduler_thread.start()
            tactic_threads.append(tactic_scheduler_thread)





        DbContainer.close_thread_sql()


        # check each thread every 20 seconds
        while 1:
            end = False
            try:
                if my.check_interval:
                    time.sleep(my.check_interval)
                    for tactic_thread in tactic_threads:
                        tactic_thread._check()

                else:
                    # FIXME: break for now (for windows service)
                    break

            except KeyboardInterrupt, e:
                print "Keyboard interrupt ... exiting Tactic"
                for tactic_thread in tactic_threads:
                    tactic_thread.end = True
                    end = True

            if end:
                break
开发者ID:hellios78,项目名称:TACTIC,代码行数:104,代码来源:monitor.py

示例9: execute

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_thread_sql [as 别名]
    def execute(my):
        from pyasm.security import Batch

        Batch(login_code="admin")

        os.environ["TACTIC_MONITOR"] = "true"

        if not my.num_processes:
            my.num_processes = Config.get_value("services", "process_count")
            if my.num_processes:
                my.num_processes = int(my.num_processes)
            else:
                my.num_processes = 3

        start_port = Config.get_value("services", "start_port")

        ports_str = os.environ.get("TACTIC_PORTS")
        if not ports_str:
            ports_str = Config.get_value("services", "ports")

        if ports_str:
            ports = ports_str.split("|")
            ports = [int(x) for x in ports]
        else:
            if start_port:
                start_port = int(start_port)
            else:
                start_port = 8081
            ports = []
            for i in range(0, my.num_processes):
                ports.append(start_port + i)

        # create a number of processes
        tactic_threads = []
        # for i in range(0, my.num_processes):
        for port in ports:

            # start cherrypy
            tactic_thread = TacticThread(port)
            tactic_thread.set_dev(my.dev_mode)

            tactic_thread.start()
            tactic_threads.append(tactic_thread)
            time.sleep(1)
            # port += 1

        # start up scheduled triggers
        # from tactic.command import ScheduledTriggerMonitor
        # ScheduledTriggerMonitor.start()

        # create a separate thread for timed processes
        tactic_timed_thread = TacticTimedThread()
        tactic_timed_thread.start()

        tactic_threads.append(tactic_timed_thread)

        DbContainer.close_thread_sql()

        # check each thread every 20 seconds
        while 1:
            end = False
            try:
                if my.check_interval:
                    time.sleep(my.check_interval)
                    for tactic_thread in tactic_threads:
                        tactic_thread.check()

                else:
                    # FIXME: break for now (for windows service)
                    break

            except KeyboardInterrupt, e:
                print "Keyboard interrupt ... exiting Tactic"
                for tactic_thread in tactic_threads:
                    tactic_thread.end = True
                    end = True

            if end:
                break
开发者ID:raidios,项目名称:TACTIC,代码行数:81,代码来源:monitor.py

示例10: __init__

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_thread_sql [as 别名]

#.........这里部分代码省略.........

        try:
            sql = DbContainer.get("sthpw")
            if sql.get_database_type() != "MongoDb":
                # before batch, clean up the ticket with a NULL code
                if os.getenv('TACTIC_MODE') != 'production':
                    sql.do_update('DELETE from "ticket" where "code" is NULL')
                else:
                    start_port = Config.get_value("services", "start_port")
                    if start_port:
                        start_port = int(start_port)
                    else:
                        start_port = 8081
                    if port and int(port) == start_port:
                         sql.do_update('DELETE from "ticket" where "code" is NULL')
        except DatabaseException as e:
            # TODO: need to work on this
            print("ERROR: could not connect to [sthpw] database")
            #os.environ["TACTIC_CONFIG_PATH"] = Config.get_default_config_path()
            #Sql.set_default_vendor("Sqlite")

            Config.set_tmp_config()
            Config.reload_config()

            # try connecting again
            try:
                sql = DbContainer.get("sthpw")
            except:
                print "Could not connect to the database."
                raise


        # is it CherryPyStartup's responsibility to start batch?
        from pyasm.security import Batch
        Batch()

        self.site_dir = os.getenv("TACTIC_SITE_DIR")
        self.install_dir = os.getenv("TACTIC_INSTALL_DIR")

        # set up a simple environment.  May need a more complex one later
        self.env = Environment()


        self.setup_env()
        self.config = self.setup_sites()

        self.init_only = False

        cherrypy.startup = self


        # this initializes the web.
        # - sets up virtual implied tiggers 
        from web_init import WebInit
        WebInit().execute()

        # Windows should handle fine
        #start up the caching system if it's not windows
        cache_mode = Config.get_value("install", "cache_mode")
        if not cache_mode:
            cache_mode = 'complete'
            if os.name == 'nt':
                cache_mode = 'basic'
            
        from cache_startup import CacheStartup
        cmd = CacheStartup(mode=cache_mode)
        cmd.execute()
        cmd.init_scheduler()

        # DEPRECATED (but keeping it around"
        """
        # start up the queue system ...
        if Config.get_value("sync", "enabled") == "true":
            # start up the sync system ...
            print("Starting Transaction Sync ...")
            from tactic.command import TransactionQueueManager
            TransactionQueueManager.start()

            # start up the sync system ...
            print("Starting Watch Folder Service ...")
            from tactic.command import WatchServerFolderTask
            WatchServerFolderTask.start()
        """

        # start up scheduled triggers
        #from tactic.command import ScheduledTriggerMonitor
        #ScheduledTriggerMonitor.start()

        #from pyasm.web import Translation
        #Translation.install()


        # close all the threads in this startup thread
        from pyasm.search import DbContainer
        DbContainer.close_thread_sql()

        version = Environment.get_release_version()
        print("")
        print("Starting TACTIC v%s ..." % version)
        print("")
开发者ID:mincau,项目名称:TACTIC,代码行数:104,代码来源:cherrypy_startup.py


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