%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.** [![repo status Active](https://www.repostatus.org/badges/latest/active.svg "repo status Active")](https://www.repostatus.org/#active) [![Build Status](https://travis-ci.org/elarivie/pyReaderWriterLock.svg?branch=master)](https://travis-ci.org/elarivie/pyReaderWriterLock) [![Coverage Status](https://codecov.io/gh/elarivie/pyreaderwriterlock/branch/master/graph/badge.svg)](https://codecov.io/gh/elarivie/pyreaderwriterlock) [![BugTracker](https://img.shields.io/github/issues/elarivie/pyReaderWriterLock.svg)][pyReaderWriterLock_BugTracker] [![Python Version](https://img.shields.io/pypi/pyversions/readerwriterlock.svg)][python] [![Pypi Version](https://img.shields.io/pypi/v/readerwriterlock.svg)][pyReaderWriterLock_Pypi] [![Code size in bytes](https://img.shields.io/github/languages/code-size/elarivie/pyReaderWriterLock.svg)][pyReaderWriterLock_repo] [![License](https://img.shields.io/pypi/l/readerwriterlock.svg)][pyReaderWriterLock_License] [![Downloads](https://pepy.tech/badge/readerwriterlock)](https://pepy.tech/project/readerwriterlock) [![Downloads](https://pepy.tech/badge/readerwriterlock/month)](https://pepy.tech/project/readerwriterlock/month) [![Downloads](https://pepy.tech/badge/readerwriterlock/week)](https://pepy.tech/project/readerwriterlock/week) [![pyReaderWriterLock_repo_star](https://img.shields.io/github/stars/elarivie/pyReaderWriterLock.svg?style=social&label=Stars)][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.** [![repo status Active](https://www.repostatus.org/badges/latest/active.svg "repo status Active")](https://www.repostatus.org/#active) [![Build Status](https://travis-ci.org/elarivie/pyReaderWriterLock.svg?branch=master)](https://travis-ci.org/elarivie/pyReaderWriterLock) [![Coverage Status](https://codecov.io/gh/elarivie/pyreaderwriterlock/branch/master/graph/badge.svg)](https://codecov.io/gh/elarivie/pyreaderwriterlock) [![BugTracker](https://img.shields.io/github/issues/elarivie/pyReaderWriterLock.svg)][pyReaderWriterLock_BugTracker] [![Python Version](https://img.shields.io/pypi/pyversions/readerwriterlock.svg)][python] [![Pypi Version](https://img.shields.io/pypi/v/readerwriterlock.svg)][pyReaderWriterLock_Pypi] [![Code size in bytes](https://img.shields.io/github/languages/code-size/elarivie/pyReaderWriterLock.svg)][pyReaderWriterLock_repo] [![License](https://img.shields.io/pypi/l/readerwriterlock.svg)][pyReaderWriterLock_License] [![Downloads](https://pepy.tech/badge/readerwriterlock)](https://pepy.tech/project/readerwriterlock) [![Downloads](https://pepy.tech/badge/readerwriterlock/month)](https://pepy.tech/project/readerwriterlock/month) [![Downloads](https://pepy.tech/badge/readerwriterlock/week)](https://pepy.tech/project/readerwriterlock/week) [![pyReaderWriterLock_repo_star](https://img.shields.io/github/stars/elarivie/pyReaderWriterLock.svg?style=social&label=Stars)][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.** [![repo status Active](https://www.repostatus.org/badges/latest/active.svg "repo status Active")](https://www.repostatus.org/#active) [![Build Status](https://travis-ci.org/elarivie/pyReaderWriterLock.svg?branch=master)](https://travis-ci.org/elarivie/pyReaderWriterLock) [![Coverage Status](https://codecov.io/gh/elarivie/pyreaderwriterlock/branch/master/graph/badge.svg)](https://codecov.io/gh/elarivie/pyreaderwriterlock) [![BugTracker](https://img.shields.io/github/issues/elarivie/pyReaderWriterLock.svg)][pyReaderWriterLock_BugTracker] [![Python Version](https://img.shields.io/pypi/pyversions/readerwriterlock.svg)][python] [![Pypi Version](https://img.shields.io/pypi/v/readerwriterlock.svg)][pyReaderWriterLock_Pypi] [![Code size in bytes](https://img.shields.io/github/languages/code-size/elarivie/pyReaderWriterLock.svg)][pyReaderWriterLock_repo] [![License](https://img.shields.io/pypi/l/readerwriterlock.svg)][pyReaderWriterLock_License] [![Downloads](https://pepy.tech/badge/readerwriterlock)](https://pepy.tech/project/readerwriterlock) [![Downloads](https://pepy.tech/badge/readerwriterlock/month)](https://pepy.tech/project/readerwriterlock/month) [![Downloads](https://pepy.tech/badge/readerwriterlock/week)](https://pepy.tech/project/readerwriterlock/week) [![pyReaderWriterLock_repo_star](https://img.shields.io/github/stars/elarivie/pyReaderWriterLock.svg?style=social&label=Stars)][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 - 1.0.9-1 - Package Spec generated