python类exit()的实例源码

dummy_thread.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def exit():
    """Dummy implementation of thread.exit()."""
    raise SystemExit
ngasRetrieveFiles.py 文件源码 项目:ngas 作者: ICRAR 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def retrieveThread(optDic,
                   taskCtrl,
                   dummy):
    """
    """
    info(4,"Entering retrieveThread(%s) ..." % getThreadName())
    client = testClient().parseSrvList(optDic["servers"][NGAS_OPT_VAL])
    while (1):
        nextFileId = taskCtrl.getNextFileId()
        if (not nextFileId): thread.exit()
        nextFileId = nextFileId[:-1]
        info(1,"Next File ID: %s" % nextFileId)
        try:
            fileSize, fileObj = client.retrieveFileObj(nextFileId)
            sizeRemain = fileSize
            while (sizeRemain):
                if (sizeRemain < BLOCK_SIZE):
                    reqSize = sizeRemain
                else:
                    reqSize = BLOCK_SIZE
                buf = fileObj.read(reqSize)
                sizeRemain -= len(buf)
            taskCtrl.incBytesRecv(fileSize)
        except Exception, e:
            error("Error retrieving file with ID: %s - skipping. Error: %s" %\
                  (nextFileId, str(e)))
ngamsArchiveStressTest.py 文件源码 项目:ngas 作者: ICRAR 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def archiveThread(testObj,
                  no,
                  inc,
                  dummy):
    """
    Archive a file X times.

    testObj:  Reference to instance of ngamsTestSuite object (ngamsTestSuite).

    no:       Number allocated to thread (integer).

    inc:      Increment ARCFILE keyword before submitting each Archive Request
              (0|1/integer).

    Returns:  Void
    """
    if (inc):
        filename = "tmp/ngamsArchiveStressTest_%d.fits" % no
        cpFile("src/TinyTestFile.fits", filename)
        incArcfile(filename, step=(100 * no))
    else:
        filename = "src/TinyTestFile.fits"
    testStr = TST_STR1 % os.path.basename(filename)

    for n in range(5):
        if (not RUN_TEST):
            THREAD_STAT[no] = "STOPPED"
            break
        if (inc): incArcfile(filename)
        statObj = sendPclCmd(auth=AUTH).archive(filename)
        if (statObj.getMessage() != testStr):
            THREAD_STAT[no] = "FAILURE: Archive Request failed"
    THREAD_STAT[no] = "SUCCESS"
    thread.exit()
dummy_thread.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def start_new_thread(function, args, kwargs={}):
    """Dummy implementation of thread.start_new_thread().

    Compatibility is maintained by making sure that ``args`` is a
    tuple and ``kwargs`` is a dictionary.  If an exception is raised
    and it is SystemExit (which can be done by thread.exit()) it is
    caught and nothing is done; all other exceptions are printed out
    by using traceback.print_exc().

    If the executed function calls interrupt_main the KeyboardInterrupt will be
    raised when the function returns.

    """
    if type(args) != type(tuple()):
        raise TypeError("2nd arg must be a tuple")
    if type(kwargs) != type(dict()):
        raise TypeError("3rd arg must be a dict")
    global _main
    _main = False
    try:
        function(*args, **kwargs)
    except SystemExit:
        pass
    except:
        _traceback.print_exc()
    _main = True
    global _interrupt
    if _interrupt:
        _interrupt = False
        raise KeyboardInterrupt
dummy_thread.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def exit():
    """Dummy implementation of thread.exit()."""
    raise SystemExit
s3_uploader.py 文件源码 项目:s3_uploader 作者: charlesdaniel 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def cancel_transfer(self):
        if self.cancel_button["text"] == "Cancel":
            # If the cancel button says "Cancel" then we want to set the exit flag to True
            self._thread_should_exit = True
        elif self.cancel_button["text"] == "Clear":
            # Otherwise if the cancel button says "Clear" we have to remove the upload frame
            self.grid_forget()
acmepins.py 文件源码 项目:TanzoBot 作者: tanzilli 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def set_edge(self,value,callback,debouncingtime=0):
        if self.fd!=None:
            set_edge(self.kernel_id,value)
            thread.start_new_thread(self.wait_edge,(self.fd,callback,debouncingtime))
            return
        else:       
            thread.exit()

        return
test_socket.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def clientTearDown(self):
        self.done.set()
        thread.exit()
dummy_thread.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def start_new_thread(function, args, kwargs={}):
    """Dummy implementation of thread.start_new_thread().

    Compatibility is maintained by making sure that ``args`` is a
    tuple and ``kwargs`` is a dictionary.  If an exception is raised
    and it is SystemExit (which can be done by thread.exit()) it is
    caught and nothing is done; all other exceptions are printed out
    by using traceback.print_exc().

    If the executed function calls interrupt_main the KeyboardInterrupt will be
    raised when the function returns.

    """
    if type(args) != type(tuple()):
        raise TypeError("2nd arg must be a tuple")
    if type(kwargs) != type(dict()):
        raise TypeError("3rd arg must be a dict")
    global _main
    _main = False
    try:
        function(*args, **kwargs)
    except SystemExit:
        pass
    except:
        _traceback.print_exc()
    _main = True
    global _interrupt
    if _interrupt:
        _interrupt = False
        raise KeyboardInterrupt
dummy_thread.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def exit():
    """Dummy implementation of thread.exit()."""
    raise SystemExit
test_socket.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def clientTearDown(self):
        self.done.set()
        thread.exit()
dummy_thread.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def start_new_thread(function, args, kwargs={}):
    """Dummy implementation of thread.start_new_thread().

    Compatibility is maintained by making sure that ``args`` is a
    tuple and ``kwargs`` is a dictionary.  If an exception is raised
    and it is SystemExit (which can be done by thread.exit()) it is
    caught and nothing is done; all other exceptions are printed out
    by using traceback.print_exc().

    If the executed function calls interrupt_main the KeyboardInterrupt will be
    raised when the function returns.

    """
    if type(args) != type(tuple()):
        raise TypeError("2nd arg must be a tuple")
    if type(kwargs) != type(dict()):
        raise TypeError("3rd arg must be a dict")
    global _main
    _main = False
    try:
        function(*args, **kwargs)
    except SystemExit:
        pass
    except:
        _traceback.print_exc()
    _main = True
    global _interrupt
    if _interrupt:
        _interrupt = False
        raise KeyboardInterrupt
dummy_thread.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def exit():
    """Dummy implementation of thread.exit()."""
    raise SystemExit
dummy_thread.py 文件源码 项目:empyrion-python-api 作者: huhlig 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def start_new_thread(function, args, kwargs={}):
    """Dummy implementation of thread.start_new_thread().

    Compatibility is maintained by making sure that ``args`` is a
    tuple and ``kwargs`` is a dictionary.  If an exception is raised
    and it is SystemExit (which can be done by thread.exit()) it is
    caught and nothing is done; all other exceptions are printed out
    by using traceback.print_exc().

    If the executed function calls interrupt_main the KeyboardInterrupt will be
    raised when the function returns.

    """
    if type(args) != type(tuple()):
        raise TypeError("2nd arg must be a tuple")
    if type(kwargs) != type(dict()):
        raise TypeError("3rd arg must be a dict")
    global _main
    _main = False
    try:
        function(*args, **kwargs)
    except SystemExit:
        pass
    except:
        _traceback.print_exc()
    _main = True
    global _interrupt
    if _interrupt:
        _interrupt = False
        raise KeyboardInterrupt
dummy_thread.py 文件源码 项目:empyrion-python-api 作者: huhlig 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def exit():
    """Dummy implementation of thread.exit()."""
    raise SystemExit
runTest.py 文件源码 项目:PACCI 作者: SymSecGroup 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def runWithAccident():
    print "***ready to test with event"
    for (ip,name) in nodes:
        accidentJoin(ip)
        time.sleep(2)
    print "****all nodes restarted"
    #time.sleep(10)
    #print "****wait for key"
    #raw_input()

    interval=event_interval
    try:
        if(options.recur):
            simulateThread=threading.Thread(target=recurEventThread, args=(interval,test_time,))
        else:
            simulateThread=threading.Thread(target=simulateAccidentThread, args=(interval,test_time,))

        #simulateThread=threading.Thread(target=simulateAccidentThread,args=(interval,test_time))
        #simulateThread.start()
        simulateThread.setDaemon(True)
        simulateThread.start()
        runTest()
        GLOBAL_FLAG=False
        print "****global flag:",GLOBAL_FLAG
        simulateThread.join()

    except KeyboardInterrupt:
        exit(-1)
runTest.py 文件源码 项目:PACCI 作者: SymSecGroup 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def runWithUser():
    global GLOBAL_FLAG
    global test_time

    #reset all flag and let nodes work
    for (ip,name) in nodes:
        resetFlag(ip)

    print "***ready to test with userdefine"

    #time.sleep(10)
    #print "****wait for key"
    #raw_input()

    interval=event_interval
    try:
    #if(1):
        #simulateUserThread(interval,test_time)
        #exit(0)

        if(options.recur):
            simulateThread=threading.Thread(target=recurUserThread, args=(interval,test_time,))
        else:
            simulateThread=threading.Thread(target=simulateUserThread, args=(interval,test_time,))

        #simulateThread=threading.Thread(target=simulateAccidentThread,args=(interval,test_time))
        #simulateThread.start()
        simulateThread.setDaemon(True)
        simulateThread.start()
        runTest()
        GLOBAL_FLAG=False
        print "****global flag:",GLOBAL_FLAG
        simulateThread.join()

    except KeyboardInterrupt:
        for (ip,name) in nodes:
            resetFlag(ip)
        exit(-1)
        return
runTest.py 文件源码 项目:PACCI 作者: SymSecGroup 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def handler(a,b):
    global GLOBAL_FLAG

    GLOBAL_FLAG=False
    exit(0)
pacci.py 文件源码 项目:PACCI 作者: SymSecGroup 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def run(self):
        global options

        sleepTime = self.sleepTime
        slice = self.slice
        # print "****time limit:",slice, slice*2

        while (1):
            startTime = self.startTime
            stopTime = time.time()
            totalTime = stopTime - startTime

            # print "in timerThread, total time now %f" %(totalTime)
            if (slice * 2 <= totalTime):
                print "****Error in spark:too long time!"
                thread.interrupt_main()
                exit(0)
                thread.exit()

            if (slice <= totalTime):
                print "****Timer:timeLock is locked!"

                # reset all flag
                # nodes=readConf()
                # for (ip,name) in nodes:
                # resetFlag(ip)

                break

            # print "****timer sleep"
            # print "****pass time:", totalTime
            time.sleep(sleepTime)

        global eventThread
        # eventThread.setRun(False)

        print "****Timer:total time:%f" % (totalTime)
        options.TIME_OUT_SIGNAL = True
        print "****Timer:time over trigger:", options.TIME_OUT_SIGNAL
        thread.interrupt_main()
pacci.py 文件源码 项目:PACCI 作者: SymSecGroup 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def timer(startTime):
    global TIME_OUT_SIGNAL

    print ("in timerThread")

    sleepTime=10
    slice=options.timelimit
    total=0

    while (1):
        stopTime=time.time()
        totalTime=stopTime - startTime
        # print "in timerThread, total time now %f" %(total)
        if (slice * 2 <= totalTime):
            print "****Error in spark:too long time!"
            thread.interrupt_main()
            thread.exit()
        if (slice <= totalTime):
            print "timer:timeLock is locked!"
            break

        time.sleep(sleepTime)

    print "total time:%f" % (totalTime)

    TIME_OUT_SIGNAL=True
    # on_signal_usr1(0,0)
    # os.kill(pid,signal.SIGUSR1)


问题


面经


文章

微信
公众号

扫码关注公众号