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


Python os.abort方法代码示例

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


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

示例1: update_collection_set

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def update_collection_set(cls, item, response ,spider):
        # if cls.entry == "COLLECTION":
        cls.collection_set.add(item["pid"].split('_')[0])
        cls.process = len(cls.collection_set) - cls.init_colletion_set_size
        # for debug only
        if cls.process > cls.maxsize:
            if cls.entry == "COLLECTION":
                with open("./.trace", "wb") as f:
                    pickle.dump(cls.collection_set, f)

            # store .json file
            f = open("data_{0}.json".format('_'.join(cf.get('SRH', 'TAGS').split(" "))), 'w')
            data = [item.__dict__() for item in cls.data]
            json.dump(data, f)

            print("Crawling complete, got {0} data".format(len(cls.data)))
            f.close()
            os.abort()
            # raise CloseSpider
            # cls.signalManger.send_catch_log(signal=signals.spider_closed) 
开发者ID:vicety,项目名称:Pixiv-Crawler,代码行数:22,代码来源:pixiv-beta.py

示例2: mem_check

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def mem_check(opts):

    while True:

        if opts['gc']:
            try:
                gc.collect()
            except Exception as e:
                logging.exception(repr(e) + ' while gc.collect()')

        try:
            rss = psutil.Process(os.getpid()).memory_info().rss

            logging.info('current memory used: {rss}'.format(rss=rss))

            if rss > opts['threshold']:
                memory_dump(opts)
                os.abort()
        except Exception as e:
            logging.exception(repr(e) + ' while checking memory usage')

        finally:
            time.sleep(opts['interval']) 
开发者ID:bsc-s2,项目名称:pykit,代码行数:25,代码来源:profiling.py

示例3: _do_main

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def _do_main(self, commands):
        """
        :type commands: list of VSCtlCommand
        """
        self._reset()
        self._init_schema_helper()
        self._run_prerequisites(commands)

        idl_ = idl.Idl(self.remote, self.schema_helper)
        seqno = idl_.change_seqno
        while True:
            self._idl_wait(idl_, seqno)

            seqno = idl_.change_seqno
            if self._do_vsctl(idl_, commands):
                break

            if self.txn:
                self.txn.abort()
                self.txn = None
            # TODO:XXX
            # ovsdb_symbol_table_destroy(symtab)

        idl_.close() 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:26,代码来源:vsctl.py

示例4: execute

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def execute(self, key):
        file = "data%d" % numpy.random.randint(1, 1000)
        odb = "%s.odb" % file
        context.tmp.append(odb)
        cmd = (
            'odbsql -q "'
            + self.args["query"]
            + '" -i '
            + self.args["path"]
            + " -f newodb -o "
            + odb
        )
        print(cmd)
        if os.system(cmd):
            print("Error in filtering ODB data... Aborting")
            os.abort()
        Magics.setc("odb_filename", odb) 
开发者ID:ecmwf,项目名称:magics-python,代码行数:19,代码来源:macro.py

示例5: test_run_abort

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def test_run_abort(self):
        # returncode handles signal termination
        with support.SuppressCrashReport():
            p = subprocess.Popen([sys.executable, "-c",
                                  'import os; os.abort()'])
            p.wait()
        self.assertEqual(-p.returncode, signal.SIGABRT) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:test_subprocess.py

示例6: _async_terminate

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def _async_terminate(*_):
  async_quit()
  global _num_terminate_requests
  _num_terminate_requests += 1
  if _num_terminate_requests == 1:
    logging.info('Shutting down.')
  if _num_terminate_requests >= 3:
    logging.error('Received third interrupt signal. Terminating.')
    os.abort() 
开发者ID:elsigh,项目名称:browserscope,代码行数:11,代码来源:shutdown.py

示例7: setUp

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def setUp(self):
    self.mox = mox.Mox()
    self.mox.StubOutWithMock(os, 'abort')
    shutdown._shutting_down = False
    shutdown._num_terminate_requests = 0
    self._sigint_handler = signal.getsignal(signal.SIGINT)
    self._sigterm_handler = signal.getsignal(signal.SIGTERM) 
开发者ID:elsigh,项目名称:browserscope,代码行数:9,代码来源:shutdown_test.py

示例8: test_async_terminate_abort

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def test_async_terminate_abort(self):
    os.abort()
    self.mox.ReplayAll()
    shutdown._async_terminate()
    self.assertTrue(shutdown._shutting_down)
    shutdown._async_terminate()
    shutdown._async_terminate()
    self.mox.VerifyAll() 
开发者ID:elsigh,项目名称:browserscope,代码行数:10,代码来源:shutdown_test.py

示例9: test_run_abort

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def test_run_abort(self):
        # returncode handles signal termination
        with _SuppressCoreFiles():
            p = subprocess.Popen([sys.executable, "-c",
                                  "import os; os.abort()"])
            p.wait()
        self.assertEqual(-p.returncode, signal.SIGABRT) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_subprocess.py

示例10: test_os_abort

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def test_os_abort(self):
        # Positive
        self.TestCommandLine(("-c", "import os; os.abort()"), "", 1)
        self.TestScript((), "import os\nos.abort()", "", 1) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_stdconsole.py

示例11: __start

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def __start(self):
        "do work of starting the process"
        self.statusPipe = _StatusPipe()
        self.started = True  # do first to prevent restarts on error
        self.pid = os.fork()
        if self.pid == 0:
            try:
                self.__childStart()
            finally:
                os.abort() # should never make it here
        else:
            self.__parentStart() 
开发者ID:ComparativeGenomicsToolkit,项目名称:Comparative-Annotation-Toolkit,代码行数:14,代码来源:pipeline.py

示例12: start_mem_check_thread

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def start_mem_check_thread(threshold=1024 * 1024 * 1024,
                           gc=False,
                           size_range=None,
                           interval=1
                           ):
    """
    Start a thread in background and in daemon mode, to watch memory usage.
    If memory this process is using beyond `threshold`, a memory usage profile
    is made and is written to root logger. And process is aborted.

    `threshold`:    maximum memory a process can use before abort.
    `gc`:           whether to run gc every time before checking memory usage.
    `size_range`:   in tuple, dump only object of size in this range.
    `interval`:     memory check interval.
    """

    options = {
        'threshold': threshold,
        'gc': gc,
        'size_range': size_range,
        'interval': interval,
    }

    th = threading.Thread(target=mem_check, args=(options,))
    th.daemon = True
    th.start()

    return th 
开发者ID:bsc-s2,项目名称:pykit,代码行数:30,代码来源:profiling.py

示例13: sync_virtualchain

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def sync_virtualchain(blockchain_opts, last_block, state_engine, expected_snapshots={}, tx_filter=None ):
    """
    Synchronize the virtual blockchain state up until a given block.

    Obtain the operation sequence from the blockchain, up to and including last_block.
    That is, go and fetch each block we haven't seen since the last call to this method,
    extract the operations from them, and record in the given working_dir where we left
    off while watching the blockchain.

    Store the state engine state, consensus snapshots, and last block to the working directory.
    Return True on success
    Return False if we're supposed to stop indexing
    Abort the program on error.  The implementation should catch timeouts and connection errors
    """

    rc = False
    start = datetime.datetime.now()
    while True:
        try:

            # advance state
            rc = indexer.StateEngine.build(blockchain_opts, last_block + 1, state_engine, expected_snapshots=expected_snapshots, tx_filter=tx_filter )
            break
        
        except Exception, e:
            log.exception(e)
            log.error("Failed to synchronize chain; exiting to safety")
            os.abort() 
开发者ID:blockstack,项目名称:virtualchain,代码行数:30,代码来源:virtualchain.py

示例14: db_query_execute

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def db_query_execute(cls, cur, query, values, verbose=True):
        """
        Execute a query.
        Handle db timeouts.
        Abort on failure.
        """
        timeout = 1.0

        if verbose:
            log.debug(cls.db_format_query(query, values))

        while True:
            try:
                ret = cur.execute(query, values)
                return ret
            except sqlite3.OperationalError as oe:
                if oe.message == "database is locked":
                    timeout = timeout * 2 + timeout * random.random()
                    log.error("Query timed out due to lock; retrying in %s: %s" % (timeout, cls.db_format_query( query, values )))
                    time.sleep(timeout)
                
                else:
                    log.exception(oe)
                    log.error("FATAL: failed to execute query (%s, %s)" % (query, values))
                    log.error("\n".join(traceback.format_stack()))
                    os.abort()

            except Exception, e:
                log.exception(e)
                log.error("FATAL: failed to execute query (%s, %s)" % (query, values))
                log.error("\n".join(traceback.format_stack()))
                os.abort() 
开发者ID:blockstack,项目名称:virtualchain,代码行数:34,代码来源:indexer.py

示例15: not_reached

# 需要导入模块: import os [as 别名]
# 或者: from os import abort [as 别名]
def not_reached():
    os.abort() 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:4,代码来源:vsctl.py


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