![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Extends the base tqdm progress bar with a subscribe method that can expose updates to external (potentially non-Python) processes.
tqdm_publisher
is a small Python package that allows you to subscribe to updates from tqdm
progress bars with arbitrary callback functions.
This is useful if you want to use tqdm
to track the progress of a long-running task, but you also want to do something else with the progress information (e.g., forward it to a user interface, log it to a file, etc.).
pip install tqdm_publisher
To monitor the progress of an existing tqdm
progress bar, simply swap the tqdm
and TQDMPublisher
constructors. Then, declare a callback function to handle progress updates, and subscribe it to the TQDMPublisher
updates using the subscribe
method before iteration begins.
import random
import time
from tqdm import tqdm
N_TASKS = 100
# Create a list of tasks
durations = [ random.uniform(0, 1.0) for _ in range(N_TASKS) ]
# Create a progress bar
progress_bar = tqdm(durations)
# Iterate over the progress bar
for duration in progress_bar:
time.sleep(duration) # Execute the task
import random
import time
from tqdm_publisher import TQDMPublisher
N_TASKS = 100
durations = [ random.uniform(0, 1.0) for _ in range(N_TASKS) ]
progress_bar = TQDMPublisher(durations)
# Declare a callback function to handle progress updates
on_update = lambda info: print('Progress Update', info)
# Subscribe the callback to the TQDMPublisher
progress_bar.subscribe(on_update)
for duration in progress_bar:
time.sleep(duration)
A complete demo of tqdm_publisher
can be found in the demo
directory, which shows how to forward progress updates from the same TQDMPublisher
instance to multiple clients.
To run the demo, first install the dependencies:
pip install tqdm_publisher[demo]
Then, run the base CLI command to start the demo server and client:
tqdm_publisher demo
Note: Alternatively, you can run each part of the demo separately by running
tqdm_publisher demo --server
andtqdm_publisher demo --client
in separate terminals.
Finally, you can click the Create Progress Bar button to create a new TQDMPublisher
instance, which will begin updating based on the TQDMPublisher
instance in the Python script.
FAQs
Extends the base tqdm progress bar with a subscribe method that can expose updates to external (potentially non-Python) processes.
We found that tqdm-publisher demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.