diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-31 07:04:37 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-31 07:04:37 +0000 |
commit | 7772d1fd031951172e6172a000957a2196f95ea4 (patch) | |
tree | a92e48bcfaec46cbe4d2b204590ddf888c6a32a2 | |
parent | 6d6331cdc446e24cf87ce9c5d6fc4c96ae740d40 (diff) |
automatic import of python-locks
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-locks.spec | 256 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 258 insertions, 0 deletions
@@ -0,0 +1 @@ +/locks-0.1.1.tar.gz diff --git a/python-locks.spec b/python-locks.spec new file mode 100644 index 0000000..ab62913 --- /dev/null +++ b/python-locks.spec @@ -0,0 +1,256 @@ +%global _empty_manifest_terminate_build 0 +Name: python-locks +Version: 0.1.1 +Release: 1 +Summary: POSIX file system locking using flock +License: MIT +URL: https://github.com/rossmacarthur/locks +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/29/7c/94a8e0b91c0b9cec5adf7cd7dc871b215835ca1ba9e3f595fee8a0fb9e49/locks-0.1.1.tar.gz +BuildArch: noarch + +Requires: python3-monotonic + +%description +# locks + +[](https://pypi.org/project/locks/) +[](https://travis-ci.org/rossmacarthur/locks) + +POSIX file system locking using [flock](https://linux.die.net/man/2/flock). + +## Getting started + +Install this package with + +```sh +pip install locks +``` + +## Usage + +The simplest usage is to block indefinitely until the lock is acquired + +```python +from locks import Mutex + +with Mutex('/tmp/file.lock'): + # do exclusive stuff here +``` + +Alternatively, block until a timeout is reached + +```python +from locks import Mutex + +try: + with Mutex('/tmp/file.lock', timeout=0.5): + # do exclusive stuff here +except BlockingIOError: + # handle the failure to acquire the lock +``` + +Finally, a common paradigm is to attempt to acquire the lock without blocking, +do something, and then block indefinitely. Here `callback` will be called once +if we cannot immediately acquire the lock, and then we will block indefinitely. + +```python +def callback(): + print("Blocking: waiting for file lock on '/tmp/file.lock'") + +with Mutex('/tmp/file.lock', callback=callback): + # do exclusive stuff here +``` + +If both `callback` and `timeout` are used then we will attempt to +acquire the lock until the `timeout` is reached, and then we will block +indefinitely. + +## License + +This project is licensed under the MIT License. See the [LICENSE] file. + +[LICENSE]: LICENSE + + + + +%package -n python3-locks +Summary: POSIX file system locking using flock +Provides: python-locks +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-locks +# locks + +[](https://pypi.org/project/locks/) +[](https://travis-ci.org/rossmacarthur/locks) + +POSIX file system locking using [flock](https://linux.die.net/man/2/flock). + +## Getting started + +Install this package with + +```sh +pip install locks +``` + +## Usage + +The simplest usage is to block indefinitely until the lock is acquired + +```python +from locks import Mutex + +with Mutex('/tmp/file.lock'): + # do exclusive stuff here +``` + +Alternatively, block until a timeout is reached + +```python +from locks import Mutex + +try: + with Mutex('/tmp/file.lock', timeout=0.5): + # do exclusive stuff here +except BlockingIOError: + # handle the failure to acquire the lock +``` + +Finally, a common paradigm is to attempt to acquire the lock without blocking, +do something, and then block indefinitely. Here `callback` will be called once +if we cannot immediately acquire the lock, and then we will block indefinitely. + +```python +def callback(): + print("Blocking: waiting for file lock on '/tmp/file.lock'") + +with Mutex('/tmp/file.lock', callback=callback): + # do exclusive stuff here +``` + +If both `callback` and `timeout` are used then we will attempt to +acquire the lock until the `timeout` is reached, and then we will block +indefinitely. + +## License + +This project is licensed under the MIT License. See the [LICENSE] file. + +[LICENSE]: LICENSE + + + + +%package help +Summary: Development documents and examples for locks +Provides: python3-locks-doc +%description help +# locks + +[](https://pypi.org/project/locks/) +[](https://travis-ci.org/rossmacarthur/locks) + +POSIX file system locking using [flock](https://linux.die.net/man/2/flock). + +## Getting started + +Install this package with + +```sh +pip install locks +``` + +## Usage + +The simplest usage is to block indefinitely until the lock is acquired + +```python +from locks import Mutex + +with Mutex('/tmp/file.lock'): + # do exclusive stuff here +``` + +Alternatively, block until a timeout is reached + +```python +from locks import Mutex + +try: + with Mutex('/tmp/file.lock', timeout=0.5): + # do exclusive stuff here +except BlockingIOError: + # handle the failure to acquire the lock +``` + +Finally, a common paradigm is to attempt to acquire the lock without blocking, +do something, and then block indefinitely. Here `callback` will be called once +if we cannot immediately acquire the lock, and then we will block indefinitely. + +```python +def callback(): + print("Blocking: waiting for file lock on '/tmp/file.lock'") + +with Mutex('/tmp/file.lock', callback=callback): + # do exclusive stuff here +``` + +If both `callback` and `timeout` are used then we will attempt to +acquire the lock until the `timeout` is reached, and then we will block +indefinitely. + +## License + +This project is licensed under the MIT License. See the [LICENSE] file. + +[LICENSE]: LICENSE + + + + +%prep +%autosetup -n locks-0.1.1 + +%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-locks -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.1-1 +- Package Spec generated @@ -0,0 +1 @@ +0595f0298ace6535db1f1b42605e2f96 locks-0.1.1.tar.gz |