Python os.abort() Examples

The following are code examples for showing how to use os.abort(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: pykit   Author: baishancloud   File: profiling.py    (MIT License) View Source Project 9 votes vote down vote up
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']) 
Example 2
Project: IPViewer   Author: gauravssnl   File: ipviewer.py    (license) View Source Project 6 votes vote down vote up
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)] 
Example 3
Project: PyS60-Projects   Author: gauravssnl   File: ipviewer.py    (license) View Source Project 6 votes vote down vote up
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)] 
Example 4
Project: ryu-lagopus-ext   Author: lagopus   File: vsctl.py    (license) View Source Project 6 votes vote down vote up
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() 
Example 5
Project: rpi-rx5808-stream   Author: xythobuz   File: rpi-rx5808-stream.py    (license) View Source Project 6 votes vote down vote up
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() 
Example 6
Project: deb-ryu   Author: openstack   File: vsctl.py    (license) View Source Project 6 votes vote down vote up
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() 
Example 7
Project: pykit   Author: baishancloud   File: profiling.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 8
Project: IPViewer   Author: gauravssnl   File: ipviewer.py    (license) View Source Project 5 votes vote down vote up
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() 
Example 9
Project: Bitly-Symbian   Author: gauravssnl   File: default.py    (license) View Source Project 5 votes vote down vote up
def exit():
    os.abort() 
Example 10
Project: zippy   Author: securesystemslab   File: test_subprocess.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 11
Project: oil   Author: oilshell   File: test_subprocess.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 12
Project: python2-tracer   Author: extremecoders-re   File: test_subprocess.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 13
Project: PyS60-Projects   Author: gauravssnl   File: PyPastebin.py    (license) View Source Project 5 votes vote down vote up
def exit():
    sets.LOGIN = 0
    sets.save()
    os.abort() 
Example 14
Project: PyS60-Projects   Author: gauravssnl   File: ipviewer.py    (license) View Source Project 5 votes vote down vote up
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() 
Example 15
Project: Comparative-Annotation-Toolkit   Author: ComparativeGenomicsToolkit   File: pipeline.py    (license) View Source Project 5 votes vote down vote up
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() 
Example 16
Project: web_ctp   Author: molebot   File: test_subprocess.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 17
Project: ryu-lagopus-ext   Author: lagopus   File: vsctl.py    (license) View Source Project 5 votes vote down vote up
def not_reached():
    os.abort() 
Example 18
Project: pefile.pypy   Author: cloudtracer   File: test_subprocess.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 19
Project: ouroboros   Author: pybee   File: test_subprocess.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 20
Project: ndk-python   Author: gittor   File: test_subprocess.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 21
Project: Deploy_XXNET_Server   Author: jzp820927   File: shutdown_test.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 22
Project: Deploy_XXNET_Server   Author: jzp820927   File: shutdown_test.py    (license) View Source Project 5 votes vote down vote up
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() 
Example 23
Project: Deploy_XXNET_Server   Author: jzp820927   File: shutdown.py    (license) View Source Project 5 votes vote down vote up
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() 
Example 24
Project: kbe_server   Author: xiaohaoppy   File: test_subprocess.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 25
Project: deb-ryu   Author: openstack   File: vsctl.py    (license) View Source Project 5 votes vote down vote up
def not_reached():
    os.abort()