Skip to content

Use without context manager? #301

@GammaGames

Description

@GammaGames

This is a nice library! It covers most of my use cases, but there's one I can't figure out.

Sometimes I want to use a progress bar for something that doesn't work nicely with context managers. This is usually because I have to do something with a callback, either I'm batch processing with threads or processing a large file.

Some pseudo code, hopefully it helps explain:

data = range(10)
my_bar = alive_bar(len(data))  # create the bar with a known length

func _callback(processed_data):
  bar.next(len(processed_data))  # amount is optional, but can be > 1

process_with_callback(data, callback=_callback)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions