diff options
author | CoprDistGit <infra@openeuler.org> | 2023-04-10 12:54:33 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-04-10 12:54:33 +0000 |
commit | 6ee675a493e74e2a922ad4dee95882507daeef5b (patch) | |
tree | f24a50c1104343da0b564531ce8296760d8679a8 | |
parent | 1a39c334ac4ec3a5e1d1d5aa78eb7417423a0160 (diff) |
automatic import of python-readerwriterlock
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-readerwriterlock.spec | 289 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 291 insertions, 0 deletions
@@ -0,0 +1 @@ +/readerwriterlock-1.0.9.tar.gz diff --git a/python-readerwriterlock.spec b/python-readerwriterlock.spec new file mode 100644 index 0000000..dd6ea39 --- /dev/null +++ b/python-readerwriterlock.spec @@ -0,0 +1,289 @@ +%global _empty_manifest_terminate_build 0 +Name: python-readerwriterlock +Version: 1.0.9 +Release: 1 +Summary: A python implementation of the three Reader-Writer problems. +License: MIT +URL: https://github.com/elarivie/pyReaderWriterLock +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/a4/b9/6b7c390440ec23bf5fdf33e76d6c3b697a788b983c11cb2739d6541835d6/readerwriterlock-1.0.9.tar.gz +BuildArch: noarch + +Requires: python3-typing-extensions + +%description +**A python implementation of a solution for the three Reader-Writer problems.** +[](https://www.repostatus.org/#active) +[](https://travis-ci.org/elarivie/pyReaderWriterLock) +[](https://codecov.io/gh/elarivie/pyreaderwriterlock) +[][pyReaderWriterLock_BugTracker] +[][python] +[][pyReaderWriterLock_Pypi] +[][pyReaderWriterLock_repo] +[][pyReaderWriterLock_License] +[](https://pepy.tech/project/readerwriterlock) +[](https://pepy.tech/project/readerwriterlock/month) +[](https://pepy.tech/project/readerwriterlock/week) +[][pyReaderWriterLock_repo_star] +Not only does it implement the reader-writer problems, it is also compliant with the python [lock interface](https://docs.python.org/3/library/threading.html#threading.Lock) which among others include support for timeout. +For reading about the theory behind the reader-writer problems refer to [Wikipedia](https://wikipedia.org/wiki/Readers–writers_problem). +# Installation +Install the python package [readerwriterlock](https://pypi.python.org/pypi/readerwriterlock) +```bash +python3 -m pip install -U readerwriterlock +``` +# Usage +1. Choose a rwlock class base on your access priority need and feature need which is going to be use by the threads: +| Priority | +Speed | +Downgradable* | +|---------------------------------------------------------------|-----------------|---------------| +| **Reader priority** (*aka First readers-writers problem*) | RWLockRead | RWLockReadD | +| **Writer priority** (*aka Second readers-writers problem*) | RWLockWrite | RWLockWriteD | +| **Fair priority** (*aka Third readers-writers problem*) | RWLockFair | RWLockFairD | +* **Downgradable** feature allows the locks to be atomically downgraded from being locked in write-mode to locked in read-mode +ⓘ Downgradable classes come with a theoretical ~20% negative effect on performance for acquiring and releasing locks. +2. Instantiate an instance of the chosen RWLock class: +```python +from readerwriterlock import rwlock +a = rwlock.RWLockFairD() +``` +3. Generate read locks and write locks using the following methods: +```python + a_reader_lock = a.gen_rlock() + a_writer_lock = a.gen_wlock() +``` +4. Use the generated read/write locks to protect section in your code: +## Pythonic usage example +```python +with a.gen_rlock(): + #Read stuff +with a.gen_wlock(): + #Write stuff +``` +## Use case (Timeout) example +```python +b = a.gen_wlock() +if b.acquire(blocking=True, timeout=5): + try: + #Do stuff + finally: + b.release() +``` +## Use case (Downgrade) example +```python +b = a.gen_wlock() +if b.acquire(): + try: + #Read/Write stuff + b = b.downgrade() + #Read stuff + finally: + b.release() +``` +## Live example +Refer to the file [test_rwlock.py](tests/test_rwlock.py) which has above 90% line coverage of [rwlock.py](readerwriterlock/rwlock.py). +The tests can be initiated by doing +```bash +make check.test.coverage +``` + +%package -n python3-readerwriterlock +Summary: A python implementation of the three Reader-Writer problems. +Provides: python-readerwriterlock +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-readerwriterlock +**A python implementation of a solution for the three Reader-Writer problems.** +[](https://www.repostatus.org/#active) +[](https://travis-ci.org/elarivie/pyReaderWriterLock) +[](https://codecov.io/gh/elarivie/pyreaderwriterlock) +[][pyReaderWriterLock_BugTracker] +[][python] +[][pyReaderWriterLock_Pypi] +[][pyReaderWriterLock_repo] +[][pyReaderWriterLock_License] +[](https://pepy.tech/project/readerwriterlock) +[](https://pepy.tech/project/readerwriterlock/month) +[](https://pepy.tech/project/readerwriterlock/week) +[][pyReaderWriterLock_repo_star] +Not only does it implement the reader-writer problems, it is also compliant with the python [lock interface](https://docs.python.org/3/library/threading.html#threading.Lock) which among others include support for timeout. +For reading about the theory behind the reader-writer problems refer to [Wikipedia](https://wikipedia.org/wiki/Readers–writers_problem). +# Installation +Install the python package [readerwriterlock](https://pypi.python.org/pypi/readerwriterlock) +```bash +python3 -m pip install -U readerwriterlock +``` +# Usage +1. Choose a rwlock class base on your access priority need and feature need which is going to be use by the threads: +| Priority | +Speed | +Downgradable* | +|---------------------------------------------------------------|-----------------|---------------| +| **Reader priority** (*aka First readers-writers problem*) | RWLockRead | RWLockReadD | +| **Writer priority** (*aka Second readers-writers problem*) | RWLockWrite | RWLockWriteD | +| **Fair priority** (*aka Third readers-writers problem*) | RWLockFair | RWLockFairD | +* **Downgradable** feature allows the locks to be atomically downgraded from being locked in write-mode to locked in read-mode +ⓘ Downgradable classes come with a theoretical ~20% negative effect on performance for acquiring and releasing locks. +2. Instantiate an instance of the chosen RWLock class: +```python +from readerwriterlock import rwlock +a = rwlock.RWLockFairD() +``` +3. Generate read locks and write locks using the following methods: +```python + a_reader_lock = a.gen_rlock() + a_writer_lock = a.gen_wlock() +``` +4. Use the generated read/write locks to protect section in your code: +## Pythonic usage example +```python +with a.gen_rlock(): + #Read stuff +with a.gen_wlock(): + #Write stuff +``` +## Use case (Timeout) example +```python +b = a.gen_wlock() +if b.acquire(blocking=True, timeout=5): + try: + #Do stuff + finally: + b.release() +``` +## Use case (Downgrade) example +```python +b = a.gen_wlock() +if b.acquire(): + try: + #Read/Write stuff + b = b.downgrade() + #Read stuff + finally: + b.release() +``` +## Live example +Refer to the file [test_rwlock.py](tests/test_rwlock.py) which has above 90% line coverage of [rwlock.py](readerwriterlock/rwlock.py). +The tests can be initiated by doing +```bash +make check.test.coverage +``` + +%package help +Summary: Development documents and examples for readerwriterlock +Provides: python3-readerwriterlock-doc +%description help +**A python implementation of a solution for the three Reader-Writer problems.** +[](https://www.repostatus.org/#active) +[](https://travis-ci.org/elarivie/pyReaderWriterLock) +[](https://codecov.io/gh/elarivie/pyreaderwriterlock) +[][pyReaderWriterLock_BugTracker] +[][python] +[][pyReaderWriterLock_Pypi] +[][pyReaderWriterLock_repo] +[][pyReaderWriterLock_License] +[](https://pepy.tech/project/readerwriterlock) +[](https://pepy.tech/project/readerwriterlock/month) +[](https://pepy.tech/project/readerwriterlock/week) +[][pyReaderWriterLock_repo_star] +Not only does it implement the reader-writer problems, it is also compliant with the python [lock interface](https://docs.python.org/3/library/threading.html#threading.Lock) which among others include support for timeout. +For reading about the theory behind the reader-writer problems refer to [Wikipedia](https://wikipedia.org/wiki/Readers–writers_problem). +# Installation +Install the python package [readerwriterlock](https://pypi.python.org/pypi/readerwriterlock) +```bash +python3 -m pip install -U readerwriterlock +``` +# Usage +1. Choose a rwlock class base on your access priority need and feature need which is going to be use by the threads: +| Priority | +Speed | +Downgradable* | +|---------------------------------------------------------------|-----------------|---------------| +| **Reader priority** (*aka First readers-writers problem*) | RWLockRead | RWLockReadD | +| **Writer priority** (*aka Second readers-writers problem*) | RWLockWrite | RWLockWriteD | +| **Fair priority** (*aka Third readers-writers problem*) | RWLockFair | RWLockFairD | +* **Downgradable** feature allows the locks to be atomically downgraded from being locked in write-mode to locked in read-mode +ⓘ Downgradable classes come with a theoretical ~20% negative effect on performance for acquiring and releasing locks. +2. Instantiate an instance of the chosen RWLock class: +```python +from readerwriterlock import rwlock +a = rwlock.RWLockFairD() +``` +3. Generate read locks and write locks using the following methods: +```python + a_reader_lock = a.gen_rlock() + a_writer_lock = a.gen_wlock() +``` +4. Use the generated read/write locks to protect section in your code: +## Pythonic usage example +```python +with a.gen_rlock(): + #Read stuff +with a.gen_wlock(): + #Write stuff +``` +## Use case (Timeout) example +```python +b = a.gen_wlock() +if b.acquire(blocking=True, timeout=5): + try: + #Do stuff + finally: + b.release() +``` +## Use case (Downgrade) example +```python +b = a.gen_wlock() +if b.acquire(): + try: + #Read/Write stuff + b = b.downgrade() + #Read stuff + finally: + b.release() +``` +## Live example +Refer to the file [test_rwlock.py](tests/test_rwlock.py) which has above 90% line coverage of [rwlock.py](readerwriterlock/rwlock.py). +The tests can be initiated by doing +```bash +make check.test.coverage +``` + +%prep +%autosetup -n readerwriterlock-1.0.9 + +%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-readerwriterlock -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.9-1 +- Package Spec generated @@ -0,0 +1 @@ +8ab86382fba7da8b7c88a1b5e7cec8e6 readerwriterlock-1.0.9.tar.gz |