Skip to main content

processing timer module for running on the cloud with the quota time like Kaggle and colab

Project description

TQuota

Processing timer module: help if the code is running on the cloud server which has a quota limitation, such as kaggle and colab which have a limit for 9 hours of processing on each session

quota class

The package has only one class (quota) that has two parameters

  • quota_time: type (str) default value (6h) : represent the quota time for the session
  • gap_time: type (str) default value (30m): represent the time gap between the quota limit and the actual closing time for the session

The time has a strict format to be passed with; it has to part dw while d: represent the time as digits w: the time and one character(w) to represent the time period

  • s : Seconds
  • m : Minutes
  • h : Hours
  • d : Days

functions

quota class has two functions:

  • time_up : return True if the process reaches it is limit
  • hastime : return True if the process still has time to process

install

you can install the package from pypi.

pip install tquota

usage

Import the quota class as following

from tquota import quota

Example on using the package:

  • Using time_up function:
from tquota import quota
import time
# quota _time was set for 1 minute and the gap _time as 30 second
qt = quota('1m','30s')
for i in range(1000):
    time.sleep(1)
    if qt.time_up():
        print('The process has reached the limited time')
        break
  • Using hastime function:
from tquota import quota
import time
# quota _time was set for 1 minute and the gap _time as 30 second
qt = quota('1m','30s')
for i in range(1000):
    time.sleep(1)
    if not qt.hastime():
        print('The process has reached the limited time')
        break

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

tquota-0.0.2.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

tquota-0.0.2-py3-none-any.whl (15.5 kB view hashes)

Uploaded Python 3

Supported by

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