Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

date-time-event

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-time-event

A very simple package to trigger events at a specific DateTime.

  • 0.0.1
  • Source
  • PyPI
  • Socket score

Maintainers
1

date-time-event

Codacy Badge Codacy Badge FOSSA Status HitCount

A very simple package to trigger events at a specific DateTime.

Installation

Use the package manager pip to install with the following command:

pip install date-time-event

If you would like to get the latest master or branch from github, you could also:

pip install git+https://github.com/Saadmairaj/date-time-event

Or even select a specific revision (branch/tag/commit):

pip install git+https://github.com/Saadmairaj/date-time-event@master

Usage

It is very simple and easy to use. First import the class which can be used either as a decorator or a thread function.

from date_time_event import Untiltime

The Untiltime class is threaded based timer which will wait till the given date or timer is met. As it runs on a separate thread, it doesn't effect the main thread or lock it.

from datetime import datetime, timedelta
from date_time_event import Untiltime

# Current datetime with 5 seconds in future.
date = datetime.now() + timedelta(0, 5)


@Untiltime(dateOrtime=date)
def function():
    print('Hello! Its time!', datetime.now())


function()
print('Function will be call at: %s \n' % date)
  • Untiltime decorator options. Syntax: @Untiltime( **options )

    OptionsDescription
    functionPass Target function.
    dateOrtimeGive date or time for the function to trigger if None give function will be a threaded function which can only run once. The date, time or datetime should be an instance of datetime module.
    nameA string used for identification purposes only. Just like in thread
    joinWait until the thread terminates. This blocks the calling thread until the thread whose join() method is called terminates.
    groupReserved for future extension when a ThreadGroup class is implemented.
    daemonA boolean value indicating whether this thread is a daemon thread (True) or not (False).
    argsThe args is the argument tuple for the target invocation. Defaults to ().
    kwargsThe kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.

The Untiltime class can also be used as thread class. Like so

from datetime import datetime, timedelta
from date_time_event import Untiltime

def function():
    print('Hello! Its time!', datetime.now())


# Current datetime with 5 seconds in future.
date = datetime.now() + timedelta(0, 5)

th = Untiltime(function, dateOrtime=date)
th.start()

print('Function will be call at: %s \n' % date)

Once the thread is called it can be stopped or cancel if called .cancel() method before the datetime event occurs.

  • Set date can be changed with property date, if the thread has not started.
from datetime import datetime, timedelta
from date_time_event import Untiltime

def function():
    print('Hello! Its time!', datetime.now())


# Current datetime with 5 seconds in future.
date = datetime.now() + timedelta(0, 1)

th = Untiltime(function, dateOrtime=date)
# Initializing new date
th.date = datetime.now() + timedelta(0, 5)
th.start()

print('Function will be call at: %s \n' % th.date)

License

FOSSA Status

Keywords

FAQs


Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc