当前位置: 首页>>代码示例>>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;未经允许,请勿转载。