當前位置: 首頁>>代碼示例>>Python>>正文


Python stderr.flush方法代碼示例

本文整理匯總了Python中sys.stderr.flush方法的典型用法代碼示例。如果您正苦於以下問題:Python stderr.flush方法的具體用法?Python stderr.flush怎麽用?Python stderr.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sys.stderr的用法示例。


在下文中一共展示了stderr.flush方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _continue_with_batch

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def _continue_with_batch(self):
        """
        Flushes one of batches (the longest one by default).

        :param assert_no_batch: indicates whether exception must be
                                raised if there is no batch to flush
        :return: the batch that was flushed, if there was a flush;
                 otherwise, ``None``.

        """
        batch = self._select_batch_to_flush()
        if batch is None:
            if _debug_options.DUMP_FLUSH_BATCH:
                debug.write("@async: no batch to flush")
            else:
                return None
        self._batches.remove(batch)
        self._flush_batch(batch)
        return batch 
開發者ID:quora,項目名稱:asynq,代碼行數:21,代碼來源:scheduler.py

示例2: try_time_based_dump

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def try_time_based_dump(self, last_task=None):
        current_time = time.time()
        if (
            current_time - self._last_dump_time
        ) < _debug_options.SCHEDULER_STATE_DUMP_INTERVAL:
            return
        self._last_dump_time = current_time
        debug.write(
            "\n--- Scheduler state dump: --------------------------------------------"
        )
        try:
            self.dump()
            if last_task is not None:
                debug.write("Last task: %s" % debug.str(last_task), 1)
        finally:
            debug.write(
                "----------------------------------------------------------------------\n"
            )
            stdout.flush()
            stderr.flush() 
開發者ID:quora,項目名稱:asynq,代碼行數:22,代碼來源:scheduler.py

示例3: evaluate

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def evaluate(operations, DEBUG=False):
    from subprocess import Popen, PIPE

    if DEBUG:
        print
        print operations
        print
    inp = send(operations)
    if DEBUG:
        print inp
        print
    with open('vhe.in', 'w') as f:
        f.write(inp)
    output, error = Popen(['./vhe'], stdin=PIPE, stdout=PIPE, shell=True).communicate('')
    if DEBUG:
        print output
        print
    
    if error:
        from sys import stderr
        stderr.write(error + '\n')
        stderr.flush()

    return recv(output) 
開發者ID:jamespayor,項目名稱:vector-homomorphic-encryption,代碼行數:26,代碼來源:hevector.py

示例4: _flush_batch

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def _flush_batch(self, batch):
        self.on_before_batch_flush(batch)
        try:
            if _debug_options.COLLECT_PERF_STATS:
                start = utime()
                batch.flush()
                batch.dump_perf_stats(utime() - start)
            else:
                batch.flush()
        finally:
            self.on_after_batch_flush(batch)
        return 0 
開發者ID:quora,項目名稱:asynq,代碼行數:14,代碼來源:scheduler.py

示例5: dump_error

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def dump_error(error, tb=None):
    """Dumps errors w/async stack traces."""
    try:
        stderr.write("\n" + (format_error(error, tb=tb) or "No error"))
    finally:
        stdout.flush()
        stderr.flush() 
開發者ID:quora,項目名稱:asynq,代碼行數:9,代碼來源:debug.py

示例6: dump_stack

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def dump_stack(skip=0, limit=None):
    """Dumps current stack trace."""
    skip += 2  # To skip dump_stack and traceback.extract_stack
    if limit is None:
        limit = options.STACK_DUMP_LIMIT
    print("--- Stack trace: -----------------------------------------------------")
    try:
        stack = traceback.extract_stack(limit=None if limit is None else limit + skip)
        print("".join(traceback.format_list(stack[:-skip])), end="")
    finally:
        print("----------------------------------------------------------------------")
        stdout.flush() 
開發者ID:quora,項目名稱:asynq,代碼行數:14,代碼來源:debug.py

示例7: async_exception_hook

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def async_exception_hook(type, error, tb):
    """Exception hook capable of printing async stack traces."""

    stdout.flush()
    stderr.flush()
    if _use_original_exc_handler and original_hook is not None:
        original_hook(type, error, tb)
    dump_error(error, tb=tb) 
開發者ID:quora,項目名稱:asynq,代碼行數:10,代碼來源:debug.py

示例8: log

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def log(msg):
    stderr.write("%s\n" % msg)
    stderr.flush() 
開發者ID:mazaclub,項目名稱:encompass,代碼行數:5,代碼來源:trezor.py

示例9: tick

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def tick(self):
        self.cur += 1
        if self.cur % self.step == 0:
            stderr.write( str(self.cur ) )
            stderr.write( "\r" )
            stderr.flush() 
開發者ID:Merck,項目名稱:DeepNeuralNet-QSAR,代碼行數:8,代碼來源:counter.py

示例10: done

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def done(self):
        stderr.write( str(self.cur ) )
        stderr.write( "\n" )
        stderr.flush() 
開發者ID:Merck,項目名稱:DeepNeuralNet-QSAR,代碼行數:6,代碼來源:counter.py

示例11: ProgressLine

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def ProgressLine(line):
    stderr.write(line)
    stderr.write( "\r" )
    stderr.flush() 
開發者ID:Merck,項目名稱:DeepNeuralNet-QSAR,代碼行數:6,代碼來源:counter.py

示例12: clean

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def clean():
    """Remove the hitch directory entirely."""
    if hitchdir.hitch_exists():
        hitchdir.remove_hitch_directory_if_exists()
    else:
        stderr.write("No hitch directory found. Doing nothing.\n")
        stderr.flush() 
開發者ID:hitchtest,項目名稱:hitch,代碼行數:9,代碼來源:commandline.py

示例13: get_hitch_directory_or_fail

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def get_hitch_directory_or_fail():
    directory, directories_checked = _check_for_directory()
    if not directory:
        stderr.write(languagestrings.HITCH_NOT_INITIALIZED)
        stderr.write('\n'.join(directories_checked))
        stderr.flush()
        exit(1)
    return directory 
開發者ID:hitchtest,項目名稱:hitch,代碼行數:10,代碼來源:hitchdir.py

示例14: check_hitch_directory_integrity

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def check_hitch_directory_integrity():
    directory, _ = _check_for_directory()
    if exists(join(directory, "absdir")):
        with open(join(directory, "absdir"), "r") as absdir_handle:
            absdir = absdir_handle.read()
        if directory != absdir:
            stderr.write(languagestrings.HITCH_DIRECTORY_MOVED.format(
                directory, abspath(join(directory, os.pardir))
            ))
            stderr.flush()
            exit(1)
    if not exists(join(get_hitch_directory(), "virtualenv", "bin")):
        stderr.write(languagestrings.SOMETHING_CORRUPTED)
        stderr.flush()
        exit(1) 
開發者ID:hitchtest,項目名稱:hitch,代碼行數:17,代碼來源:hitchdir.py

示例15: warning

# 需要導入模塊: from sys import stderr [as 別名]
# 或者: from sys.stderr import flush [as 別名]
def warning(*objs):
    '''
    wrapper for writing to stderr
    '''
    print(*objs, file=stderr)
    stderr.flush() 
開發者ID:cstoeckert,項目名稱:iterativeWGCNA,代碼行數:8,代碼來源:utils.py


注:本文中的sys.stderr.flush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。