diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-04-10 15:20:07 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-04-10 15:20:07 +0000 |
| commit | 8568d1a5117a8bc287bd4268801420c47c170aa6 (patch) | |
| tree | 2e5816611a091d6d81b0cabcd2545ef886a29b97 /python-timeloop.spec | |
| parent | 0f44a3b2edeae214f3eff49f080cb0d568fce25d (diff) | |
automatic import of python-timeloop
Diffstat (limited to 'python-timeloop.spec')
| -rw-r--r-- | python-timeloop.spec | 267 |
1 files changed, 267 insertions, 0 deletions
diff --git a/python-timeloop.spec b/python-timeloop.spec new file mode 100644 index 0000000..4feb084 --- /dev/null +++ b/python-timeloop.spec @@ -0,0 +1,267 @@ +%global _empty_manifest_terminate_build 0 +Name: python-timeloop +Version: 1.0.2 +Release: 1 +Summary: An elegant way to run period tasks. +License: MIT +URL: https://github.com/sankalpjonn/timeloop +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/6a/95/3e39ee32f15a8e9dea46bb52300611a5351964eeaa393bafb0d738e90ce0/timeloop-1.0.2.tar.gz +BuildArch: noarch + + +%description +# Timeloop +Timeloop is a service that can be used to run periodic tasks after a certain interval. + + + +Each job runs on a separate thread and when the service is shut down, it waits till all tasks currently being executed are completed. + +Inspired by this blog [`here`](https://www.g-loaded.eu/2016/11/24/how-to-terminate-running-python-threads-using-signals/) + +## Installation +```sh +pip install timeloop +``` + +## Writing jobs +```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()) +``` + +## 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** + +Email me with any queries: [sankalpjonna@gmail.com](sankalpjonna@gmail.com). + + + + +%package -n python3-timeloop +Summary: An elegant way to run period tasks. +Provides: python-timeloop +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-timeloop +# Timeloop +Timeloop is a service that can be used to run periodic tasks after a certain interval. + + + +Each job runs on a separate thread and when the service is shut down, it waits till all tasks currently being executed are completed. + +Inspired by this blog [`here`](https://www.g-loaded.eu/2016/11/24/how-to-terminate-running-python-threads-using-signals/) + +## Installation +```sh +pip install timeloop +``` + +## Writing jobs +```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()) +``` + +## 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** + +Email me with any queries: [sankalpjonna@gmail.com](sankalpjonna@gmail.com). + + + + +%package help +Summary: Development documents and examples for timeloop +Provides: python3-timeloop-doc +%description help +# Timeloop +Timeloop is a service that can be used to run periodic tasks after a certain interval. + + + +Each job runs on a separate thread and when the service is shut down, it waits till all tasks currently being executed are completed. + +Inspired by this blog [`here`](https://www.g-loaded.eu/2016/11/24/how-to-terminate-running-python-threads-using-signals/) + +## Installation +```sh +pip install timeloop +``` + +## Writing jobs +```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()) +``` + +## 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** + +Email me with any queries: [sankalpjonna@gmail.com](sankalpjonna@gmail.com). + + + + +%prep +%autosetup -n timeloop-1.0.2 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-timeloop -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon Apr 10 2023 Python_Bot <Python_Bot@openeuler.org> - 1.0.2-1 +- Package Spec generated |
