semvec/pypi-packages huggingface dataset:
aqur1n-tools 2022.2.25
Collection of modules for convenient work.
License: MIT
Requires Python: >=3.5

<a href="https://github.com/aqur1n-lab/aqur1n-tools/blob/main/LICENSE">
    <img src="https://img.shields.io/badge/license-MIT-blue.svg"/>
</a>
<a href="https://github.com/aqur1n-lab/aqur1n-tools/blob/main/atools/__init__.py">
    <img src="https://img.shields.io/badge/version-2022.2.25-green.svg"/>
</a>
<a href="https://github.com/aqur1n-lab/aqur1n-tools/blob/main/atools/__init__.py">
    <img src="https://img.shields.io/badge/python-3.5+-blue.svg"/>
</a>

# aqur1n-tools
Collection of modules for convenient work.

# Installation:
[pip](https://pypi.org/project/aqur1n-tools/#description):
```python
pip install aqur1n-tools
```

# Simple examples:
```python
from atools.basic import *
print(get_directory()) # Get the directory of the current file.
```
```python
from atools.path import Path

print(str(Path("exaples") + Path("test"))) # exaples\test
```
```python
from atools.sqlite3 import *

sql = sql("my name") # Initializes the class.
sql.connect("db\\my_db.db") # Connecting to db

sql.execute(f"CREATE TABLE IF NOT EXISTS my_table (test TEXT)", func=sql.commit) # Executes the query and calls the sql.commit function
```
You can see more on the wiki: [click](https://github.com/aqur1n-lab/aqur1n-tools/wiki)
timeloop-ng 1.0.0
An elegant way to run period tasks.
License: MIT
Keywords: tasks,jobs,periodic task,interval,periodic job,flask style,decorator

# Timeloop-NG

Timeloop-NG (for next generation) is a service that can be used to run periodic
tasks after a certain interval.

It's the successor of [timeloop](https://github.com/sankalpjonn/timeloop) from 
Sankalp Jonna as pull requests were never accepted.

Each job runs on a separate thread and when the service is shut down, it waits 
till all tasks currently being executed are completed.

## Installation

```sh
pip install timeloop-ng
```

## Writing jobs

The jobs run the first time after the first wait interval.

```python
import time

from timeloop import Timeloop
from datetime import timedelta

tl = Timeloop()


@tl.job(interval=timedelta(seconds=2))
def sample_job_every_2s():
    print("2s job current time : {}".format(time.ctime()))


@tl.job(interval=timedelta(seconds=5))
def sample_job_every_5s():
    print("5s job current time : {}".format(time.ctime()))


@tl.job(interval=timedelta(seconds=10))
def sample_job_every_10s():
    print("10s job current time : {}".format(time.ctime()))
```

## Jobs that only run a certain amount of time

By default, all jobs run until they are stopped. At times you may want to run a job only once or twice.

```python
import time

from timeloop import Timeloop
from datetime import timedelta

tl = Timeloop()


@tl.job(interval=timedelta(seconds=10), num_executions=2)
def run_me_twice_with_10s_pause():
    print("10s job current time : {}".format(time.ctime()))
```

## Jobs with a different initial interval

At times, you want

```python
@tl.job(interval=timedelta(seconds=1), initial_delay=timedelta(seconds=10))
def run_after10s_and_then_every_second():
    print("job current time : {}".format(time.ctime()))


@tl.job(interval=timedelta(seconds=1), num_executions=2, initial_delay=timedelta(seconds=10))
def run_after10s_and_then_after_1second_then_stop():
    print("job current time : {}".format(time.ctime()))
```

## Start time loop in separate thread

By default timeloop starts in a separate thread.

Please do not forget to call ```tl.stop``` before exiting the program, Or else the jobs wont shut down gracefully.

```python
tl.start()

while True:
    try:
        time.sleep(1)
    except KeyboardInterrupt:
        tl.stop()
        break
```

## Start time loop in main thread

Doing this will automatically shut down the jobs gracefully when the program is killed, so no need to call ```tl.stop```

```python
tl.start(block=True)
```

## Author

* Sankalp Jonna (author of the original version)
* Christoph Becker aka [tuergeist](mailto:tuergeist@gmail.com)