Skip to main content

stop_iter

stop_iter takes an iterable and returns a new iterable that can be safely stopped using SIGINT. This is useful when you have a long-running computation, such as machine learning training loops, that you want to be able to stop without losing all of the work that has been done so far.

Installation

pip install stop_iter

Usage

The following code will print the integers until you press Ctrl+C and then print "infinity".

from stop_iter import stop_iter

def integers():
  count = 0
  while True:
    yield (count := count + 1)

for n in stop_iter(integers()):
  print(n)

print("\ninfinity")

Metadata

Release files for stop-iter 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stop-iter 0.2.4
File Size Uploaded
stop_iter-0.2.4.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stop-iter 0.2.4
File Interpreter ABI Platform
stop_iter-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 kB

Release files / stop_iter-0.2.4.tar.gz

Download URL stop_iter-0.2.4.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
aa4272fef75b4d11ae9e9466b122e17f24cddfeca166703c786295e777d4f624
BLAKE2b-256 checksum
How to use checksums
3314c022407155f6b7d45b061698e757c5b3662783d00c7607f76604c32020d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.4 Darwin/23.5.0

Release files / stop_iter-0.2.4-py3-none-any.whl

Download URL stop_iter-0.2.4-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0276a7b68653d890064870a3ab0657ed68721f46af9da1701786110e8571fb0
BLAKE2b-256 checksum
How to use checksums
f81333eef7ab26b5efcf8b8b1a30ce467ed8efa2a0d8addc888bd1178ee8e62e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.4 Darwin/23.5.0

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page