Python os 模块,abort() 实例源码

我们从Python开源项目中,提取了以下25个代码示例,用于说明如何使用os.abort()

项目:pykit    作者:baishancloud    | 项目源码 | 文件源码
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'])
项目:IPViewer    作者:gauravssnl    | 项目源码 | 文件源码
def app(self):
        appuifw.app.title=ru(title)
        appuifw.app.exit_key_handler=self.exit
        self.i=1
        self.console=Console.Console(True)
        self.text=self.console.text
        appuifw.app.body=self.console.text
        self.text.color=255,0,0
        self.text.font= "title",20
        self.write("%s by %s"%(title,self.developer))
        self.text.color=0,0,0
        self.text.font= "title",18
        if  not len(socket.access_points()):
            self.write("No Access Point is defined.Please add new APN.App will exit")
            e32.ao_sleep(2)
            os.abort()
        else:
            pass    
        self.write("Access Point: %s"%self.ap_list[self.apid_list.index(self.sets.APN)])
        self.write("Find IP:%s"%self.insta(self.sets.IPHUNT))
        self.write("Run Simple Server: %s"%self.yesno[self.sets.RUNSS])
        appuifw.app.menu=[(ru("Start"),self.start),(ru("Settings"),self.settings),(ru("About"),self.about),(ru("Exit"),self.exit)]
项目:PyS60-Projects    作者:gauravssnl    | 项目源码 | 文件源码
def app(self):
        appuifw.app.title=ru(title)
        appuifw.app.exit_key_handler=self.exit
        self.i=1
        self.console=Console.Console(True)
        self.text=self.console.text
        appuifw.app.body=self.console.text
        self.text.color=255,0,0
        self.text.font= "title",20
        self.write("%s by %s"%(title,self.developer))
        self.text.color=0,0,0
        self.text.font= "title",18
        if  not len(socket.access_points()):
            self.write("No Access Point is defined.Please add new APN.App will exit")
            e32.ao_sleep(2)
            os.abort()
        else:
            pass    
        self.write("Access Point: %s"%self.ap_list[self.apid_list.index(self.sets.APN)])
        self.write("Find IP:%s"%self.insta(self.sets.IPHUNT))
        self.write("Run Simple Server: %s"%self.yesno[self.sets.RUNSS])
        appuifw.app.menu=[(ru("Start"),self.start),(ru("Settings"),self.settings),(ru("About"),self.about),(ru("Exit"),self.exit)]
项目:ryu-lagopus-ext    作者:lagopus    | 项目源码 | 文件源码
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()
项目:rpi-rx5808-stream    作者:xythobuz    | 项目源码 | 文件源码
def determineVideoDevice():
    global video_device_searched

    if video_device != None:
        video_device_searched = video_device
        print("Selected \"{}\" as video device...".format(video_device_searched))
        return

    path = "/dev/"
    files = []
    for i in os.listdir(path):
        f = os.path.join(path, i)
        if "/dev/video" in f:
            files.append(f)

    if len(files) > 0:
        video_device_searched = files[0]
        print("Selected \"{}\" as video device...".format(video_device_searched))
    else:
        video_device_searched = None
        print("No video device found!")
        os.abort()
项目:deb-ryu    作者:openstack    | 项目源码 | 文件源码
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()
项目:pykit    作者:baishancloud    | 项目源码 | 文件源码
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
项目:IPViewer    作者:gauravssnl    | 项目源码 | 文件源码
def exit(self):

        q=appuifw.query(u"Do you really want to Exit","query")
        if q:
            try:
                self.timerip.cancel()
                self.timert.cancel()
                appuifw.app.set_exit()
            except:
                os.abort()
项目:Bitly-Symbian    作者:gauravssnl    | 项目源码 | 文件源码
def exit():
    os.abort()
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
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)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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)
项目:PyS60-Projects    作者:gauravssnl    | 项目源码 | 文件源码
def exit():
    sets.LOGIN = 0
    sets.save()
    os.abort()
项目:PyS60-Projects    作者:gauravssnl    | 项目源码 | 文件源码
def exit(self):

        q=appuifw.query(u"Do you really want to Exit","query")
        if q:
            try:
                self.timerip.cancel()
                self.timert.cancel()
                appuifw.app.set_exit()
            except:
                os.abort()
项目:Comparative-Annotation-Toolkit    作者:ComparativeGenomicsToolkit    | 项目源码 | 文件源码
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()
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
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)
项目:ryu-lagopus-ext    作者:lagopus    | 项目源码 | 文件源码
def not_reached():
    os.abort()
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
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)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
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)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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)
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
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)
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
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()
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
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()
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
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)
项目:deb-ryu    作者:openstack    | 项目源码 | 文件源码
def not_reached():
    os.abort()