summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-04-10 23:53:47 +0000
committerCoprDistGit <infra@openeuler.org>2023-04-10 23:53:47 +0000
commit681ee3e11099cf07ff8293e214dc05e40f640b23 (patch)
treed1b534f4941a738b4a114ba54133a6aba0bf132b
parent33a03f9153ef2a107eafdd45c64fa3bced0bbdcc (diff)
automatic import of python-asyncio-throttle
-rw-r--r--.gitignore1
-rw-r--r--python-asyncio-throttle.spec375
-rw-r--r--sources1
3 files changed, 377 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..c43f37a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/asyncio-throttle-1.0.2.tar.gz
diff --git a/python-asyncio-throttle.spec b/python-asyncio-throttle.spec
new file mode 100644
index 0000000..6bc4fe5
--- /dev/null
+++ b/python-asyncio-throttle.spec
@@ -0,0 +1,375 @@
+%global _empty_manifest_terminate_build 0
+Name: python-asyncio-throttle
+Version: 1.0.2
+Release: 1
+Summary: Simple, easy-to-use throttler for asyncio
+License: MIT
+URL: https://github.com/hallazzang/asyncio-throttle
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/13/6f/0e2d42c0e95d50edf63147b8a742703061945e02760f25d6a0e8f028ccb0/asyncio-throttle-1.0.2.tar.gz
+BuildArch: noarch
+
+
+%description
+# asyncio-throttle
+
+[![travis-ci](https://travis-ci.org/hallazzang/asyncio-throttle.svg?branch=master)](https://travis-ci.org/hallazzang/asyncio-throttle)
+[![pypi-version](https://badge.fury.io/py/asyncio-throttle.svg)](https://badge.fury.io/py/asyncio-throttle)
+
+Simple, easy-to-use throttler for asyncio.
+
+## Example
+
+```python
+import time
+import random
+import asyncio
+
+from asyncio_throttle import Throttler
+
+async def worker(no, throttler, n):
+ for _ in range(n):
+ await asyncio.sleep(random.random() * 2)
+
+ async with throttler:
+ print(time.time(), 'Worker #%d: Bang!' % no)
+
+async def main():
+ throttler = Throttler(rate_limit=5)
+
+ tasks = [
+ loop.create_task(worker(no, throttler, 10))
+ for no in range(5)
+ ]
+ await asyncio.wait(tasks)
+
+loop = asyncio.get_event_loop()
+loop.run_until_complete(main())
+loop.close()
+```
+
+Here I limited work rate to 5/sec while there are 5 workers.
+And the result:
+
+```plain
+1508273760.3462772 Worker #2: Bang!
+1508273760.590009 Worker #3: Bang!
+1508273760.856431 Worker #0: Bang!
+1508273761.0110679 Worker #2: Bang!
+1508273761.086856 Worker #4: Bang!
+1508273761.350699 Worker #3: Bang!
+1508273761.5906 Worker #1: Bang!
+1508273761.8655958 Worker #4: Bang!
+1508273762.224158 Worker #0: Bang!
+1508273762.600234 Worker #2: Bang!
+1508273762.694332 Worker #2: Bang!
+1508273762.726774 Worker #0: Bang!
+1508273762.944273 Worker #4: Bang!
+```
+
+## Installation
+
+```bash
+$ pip install asyncio-throttle
+```
+
+It requires Python 3.6 or later.
+
+## Usage
+
+`asyncio_throttle.Throttler` introduces simple APIs: `flush()` and
+`acquire()`. But you will not be interested in those because you can
+just use it within `with` statement and it looks nicer.
+
+First, create a throttler given desired rate limit. For example if you
+want to limit rate to 500/min, you can make it as:
+
+```python
+from asyncio_throttle import Throttler
+
+throttler = Throttler(rate_limit=500, period=60)
+```
+
+Then whenever you want to do some jobs which should have limited
+rate(e.g. sending request to server), Put it in `async with` statement:
+
+```python
+async with throttler:
+ send_a_request()
+```
+
+It's that easy. `asyncio_throttler` can be easily integrated with
+`aiohttp` too:
+
+```python
+async def worker(throttler, session):
+ while True:
+ async with throttler:
+ async with session.get('http://example.com') as resp:
+ do_some_job_with(await resp.text())
+
+ await asyncio.sleep(0.05)
+```
+
+
+
+
+%package -n python3-asyncio-throttle
+Summary: Simple, easy-to-use throttler for asyncio
+Provides: python-asyncio-throttle
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-asyncio-throttle
+# asyncio-throttle
+
+[![travis-ci](https://travis-ci.org/hallazzang/asyncio-throttle.svg?branch=master)](https://travis-ci.org/hallazzang/asyncio-throttle)
+[![pypi-version](https://badge.fury.io/py/asyncio-throttle.svg)](https://badge.fury.io/py/asyncio-throttle)
+
+Simple, easy-to-use throttler for asyncio.
+
+## Example
+
+```python
+import time
+import random
+import asyncio
+
+from asyncio_throttle import Throttler
+
+async def worker(no, throttler, n):
+ for _ in range(n):
+ await asyncio.sleep(random.random() * 2)
+
+ async with throttler:
+ print(time.time(), 'Worker #%d: Bang!' % no)
+
+async def main():
+ throttler = Throttler(rate_limit=5)
+
+ tasks = [
+ loop.create_task(worker(no, throttler, 10))
+ for no in range(5)
+ ]
+ await asyncio.wait(tasks)
+
+loop = asyncio.get_event_loop()
+loop.run_until_complete(main())
+loop.close()
+```
+
+Here I limited work rate to 5/sec while there are 5 workers.
+And the result:
+
+```plain
+1508273760.3462772 Worker #2: Bang!
+1508273760.590009 Worker #3: Bang!
+1508273760.856431 Worker #0: Bang!
+1508273761.0110679 Worker #2: Bang!
+1508273761.086856 Worker #4: Bang!
+1508273761.350699 Worker #3: Bang!
+1508273761.5906 Worker #1: Bang!
+1508273761.8655958 Worker #4: Bang!
+1508273762.224158 Worker #0: Bang!
+1508273762.600234 Worker #2: Bang!
+1508273762.694332 Worker #2: Bang!
+1508273762.726774 Worker #0: Bang!
+1508273762.944273 Worker #4: Bang!
+```
+
+## Installation
+
+```bash
+$ pip install asyncio-throttle
+```
+
+It requires Python 3.6 or later.
+
+## Usage
+
+`asyncio_throttle.Throttler` introduces simple APIs: `flush()` and
+`acquire()`. But you will not be interested in those because you can
+just use it within `with` statement and it looks nicer.
+
+First, create a throttler given desired rate limit. For example if you
+want to limit rate to 500/min, you can make it as:
+
+```python
+from asyncio_throttle import Throttler
+
+throttler = Throttler(rate_limit=500, period=60)
+```
+
+Then whenever you want to do some jobs which should have limited
+rate(e.g. sending request to server), Put it in `async with` statement:
+
+```python
+async with throttler:
+ send_a_request()
+```
+
+It's that easy. `asyncio_throttler` can be easily integrated with
+`aiohttp` too:
+
+```python
+async def worker(throttler, session):
+ while True:
+ async with throttler:
+ async with session.get('http://example.com') as resp:
+ do_some_job_with(await resp.text())
+
+ await asyncio.sleep(0.05)
+```
+
+
+
+
+%package help
+Summary: Development documents and examples for asyncio-throttle
+Provides: python3-asyncio-throttle-doc
+%description help
+# asyncio-throttle
+
+[![travis-ci](https://travis-ci.org/hallazzang/asyncio-throttle.svg?branch=master)](https://travis-ci.org/hallazzang/asyncio-throttle)
+[![pypi-version](https://badge.fury.io/py/asyncio-throttle.svg)](https://badge.fury.io/py/asyncio-throttle)
+
+Simple, easy-to-use throttler for asyncio.
+
+## Example
+
+```python
+import time
+import random
+import asyncio
+
+from asyncio_throttle import Throttler
+
+async def worker(no, throttler, n):
+ for _ in range(n):
+ await asyncio.sleep(random.random() * 2)
+
+ async with throttler:
+ print(time.time(), 'Worker #%d: Bang!' % no)
+
+async def main():
+ throttler = Throttler(rate_limit=5)
+
+ tasks = [
+ loop.create_task(worker(no, throttler, 10))
+ for no in range(5)
+ ]
+ await asyncio.wait(tasks)
+
+loop = asyncio.get_event_loop()
+loop.run_until_complete(main())
+loop.close()
+```
+
+Here I limited work rate to 5/sec while there are 5 workers.
+And the result:
+
+```plain
+1508273760.3462772 Worker #2: Bang!
+1508273760.590009 Worker #3: Bang!
+1508273760.856431 Worker #0: Bang!
+1508273761.0110679 Worker #2: Bang!
+1508273761.086856 Worker #4: Bang!
+1508273761.350699 Worker #3: Bang!
+1508273761.5906 Worker #1: Bang!
+1508273761.8655958 Worker #4: Bang!
+1508273762.224158 Worker #0: Bang!
+1508273762.600234 Worker #2: Bang!
+1508273762.694332 Worker #2: Bang!
+1508273762.726774 Worker #0: Bang!
+1508273762.944273 Worker #4: Bang!
+```
+
+## Installation
+
+```bash
+$ pip install asyncio-throttle
+```
+
+It requires Python 3.6 or later.
+
+## Usage
+
+`asyncio_throttle.Throttler` introduces simple APIs: `flush()` and
+`acquire()`. But you will not be interested in those because you can
+just use it within `with` statement and it looks nicer.
+
+First, create a throttler given desired rate limit. For example if you
+want to limit rate to 500/min, you can make it as:
+
+```python
+from asyncio_throttle import Throttler
+
+throttler = Throttler(rate_limit=500, period=60)
+```
+
+Then whenever you want to do some jobs which should have limited
+rate(e.g. sending request to server), Put it in `async with` statement:
+
+```python
+async with throttler:
+ send_a_request()
+```
+
+It's that easy. `asyncio_throttler` can be easily integrated with
+`aiohttp` too:
+
+```python
+async def worker(throttler, session):
+ while True:
+ async with throttler:
+ async with session.get('http://example.com') as resp:
+ do_some_job_with(await resp.text())
+
+ await asyncio.sleep(0.05)
+```
+
+
+
+
+%prep
+%autosetup -n asyncio-throttle-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-asyncio-throttle -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
diff --git a/sources b/sources
new file mode 100644
index 0000000..2760098
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+831534e16334514cdbd1b729b6bbba93 asyncio-throttle-1.0.2.tar.gz