Skip to main content

Bundle of timing utilities such as Timer, Stopwatch, etc.

Project description

thym PyPI version

Bundle of timing utilities such as Timer that allows you to trigger an event at a specified interval or Stopwatch to measure time etc.

Installation

There are two ways to install thym:

Install thym from PyPI (recommended):

sudo pip install thym

If you are using a virtualenv, you may want to avoid using sudo:

pip install thym

Alternatively: install thym from the GitHub source:

First, clone thym using git:

git clone https://github.com/apgeorg/thym.git

Then, cd to the thym folder and run the install command:

cd thym
sudo python setup.py install

Getting started

Timer

Timer is able to trigger a callback either periodically or as a one shot by setting the oneshot argument correspondingly. There is an elapsed property that returns the elapsed time since start() was called. Further, a remaining property is also available that returns the remaining time of the specified interval.

import thym

# Timer callback function
def timer_timeout():
  print("Timeout!")

# Create a Timer which runs periodically 
t = thym.Timer(1, timer_timeout, oneshot=False)

# Start running
t.start()

A running Timer can be stopped anytime by calling stop() as shown below. The elapsed time and remaining time are calculated accordingly.

t.stop()

Stopwatch

Stopwatch triggers a callback when stop() is called. The callback can be passed over the Stopwatch consturctor.
There is an elapsed property that returns the elapsed time since start() was called.

import thym

# Stopwatch callback function
def stopped_callback():
  print("Stopwatch stopped!")

# Create a Stopwatch 
sw = thym.Stopwatch(stopped_callback)

# Start running
sw.start()

A running Stopwach can be stopped anytime by calling stop() as shown below. Accordingly, the elapsed time is calculated.

sw.stop()

Licence

Thym is licensed under MIT. See LICENSE file for details.

Copyright © 2019 Apostolos Georgiadis.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thym-0.0.3.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thym-0.0.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file thym-0.0.3.tar.gz.

File metadata

  • Download URL: thym-0.0.3.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for thym-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1f9045a40042585cc31fb02c637caac9ab668e35806b01dc8ba5bd8c21596904
MD5 0ed8f008fc52af69d8111c12e8196e5b
BLAKE2b-256 5d90fb82c445803c3e2038a5d93425d1e54593edc938d89d73cd397bcfab4e4b

See more details on using hashes here.

File details

Details for the file thym-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: thym-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for thym-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 13a832549bf8491a9b1d75238a787effdac5a14bd30203c269f27ec40f554662
MD5 6eec0ba48c8f62b7972e9381c379d2c0
BLAKE2b-256 ec68cac3f8a508e85e858e4fb97e2855f6ee4b6a262c304ad43bfe9ef75bc08f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page