Jedutils 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {Jedutils-0.2.0 → Jedutils-0.2.2}/Jedutils.egg-info/PKG-INFO +1 -1
- {Jedutils-0.2.0 → Jedutils-0.2.2}/PKG-INFO +1 -1
- Jedutils-0.2.2/jedutils/__init__.py +3 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/asyncio/_async_redis_pipe.py +23 -1
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/asyncio/network/_dl.py +12 -3
- Jedutils-0.2.0/jedutils/__init__.py +0 -3
- {Jedutils-0.2.0 → Jedutils-0.2.2}/Jedutils.egg-info/SOURCES.txt +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/Jedutils.egg-info/dependency_links.txt +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/Jedutils.egg-info/requires.txt +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/Jedutils.egg-info/top_level.txt +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/LICENSE +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/MANIFEST.in +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/README.md +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/asyncio/__init__.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/asyncio/_concurrency_manager.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/asyncio/_run_async.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/asyncio/_rwlock.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/asyncio/network/__init__.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/databases/__init__.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/databases/_in_memory.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/math/__init__.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/math/_number_formatter.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/strings/__init__.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/strings/_chunked_text.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/jedutils/strings/_random_string.py +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/setup.cfg +0 -0
- {Jedutils-0.2.0 → Jedutils-0.2.2}/setup.py +0 -0
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
-
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
from redis import Redis
|
|
6
|
+
except ImportError:
|
|
7
|
+
Redis = None
|
|
3
8
|
|
|
4
9
|
|
|
5
10
|
class AsyncRedisPipe:
|
|
@@ -24,6 +29,7 @@ class AsyncRedisPipe:
|
|
|
24
29
|
pipe_max_size: int = 200,
|
|
25
30
|
workers: int = 8,
|
|
26
31
|
loop: asyncio.AbstractEventLoop = None,
|
|
32
|
+
debug: bool = False,
|
|
27
33
|
) -> None:
|
|
28
34
|
"""
|
|
29
35
|
Args:
|
|
@@ -38,9 +44,19 @@ class AsyncRedisPipe:
|
|
|
38
44
|
|
|
39
45
|
loop (:py:class:`asyncio.AbstractEventLoop`, *optional*):
|
|
40
46
|
The event loop to use. Defaults to :py:class:`asyncio.get_event_loop()`.
|
|
47
|
+
|
|
48
|
+
debug (``bool``, *optional*):
|
|
49
|
+
Whether to enable debug logging. Defaults to ``False``.
|
|
41
50
|
"""
|
|
51
|
+
|
|
52
|
+
if not Redis:
|
|
53
|
+
raise RuntimeError("Redis is not installed. Try pip install redis")
|
|
54
|
+
|
|
42
55
|
self.redis = redis
|
|
43
56
|
self.pipe_max_size = pipe_max_size
|
|
57
|
+
self.debug = debug
|
|
58
|
+
self.logger = logging.getLogger(__name__)
|
|
59
|
+
|
|
44
60
|
self.__queue = asyncio.Queue()
|
|
45
61
|
self.__loop = (
|
|
46
62
|
asyncio.get_event_loop()
|
|
@@ -75,6 +91,9 @@ class AsyncRedisPipe:
|
|
|
75
91
|
except asyncio.QueueEmpty:
|
|
76
92
|
break
|
|
77
93
|
else:
|
|
94
|
+
if self.debug:
|
|
95
|
+
self.logger.debug(f"Executing command: {data[1]}")
|
|
96
|
+
|
|
78
97
|
pipe.execute_command(*data[1])
|
|
79
98
|
futures.append(data[0])
|
|
80
99
|
count += 1
|
|
@@ -84,6 +103,9 @@ class AsyncRedisPipe:
|
|
|
84
103
|
async def __handle_pipe_line(self, futures: list, pipe):
|
|
85
104
|
results = await pipe.execute(False)
|
|
86
105
|
for x, result in enumerate(results):
|
|
106
|
+
if self.debug:
|
|
107
|
+
self.logger.debug(f"Result: {result}")
|
|
108
|
+
|
|
87
109
|
if isinstance(result, BaseException):
|
|
88
110
|
futures[x].set_exception(result)
|
|
89
111
|
else:
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
try:
|
|
4
|
+
import aiohttp
|
|
5
|
+
except ImportError:
|
|
6
|
+
aiohttp = None
|
|
7
|
+
|
|
3
8
|
import os
|
|
4
9
|
|
|
5
10
|
|
|
@@ -10,9 +15,9 @@ async def download_file(
|
|
|
10
15
|
ignore_status: bool = False,
|
|
11
16
|
progress_callback: callable = None,
|
|
12
17
|
thread_pool=None,
|
|
13
|
-
**kwargs
|
|
18
|
+
**kwargs,
|
|
14
19
|
) -> None:
|
|
15
|
-
"""
|
|
20
|
+
r"""
|
|
16
21
|
Asynchronously download a file from the given URL and saves it to the specified filename using chunked downloading
|
|
17
22
|
|
|
18
23
|
Example:
|
|
@@ -52,6 +57,10 @@ async def download_file(
|
|
|
52
57
|
Raises:
|
|
53
58
|
:py:class:`aiohttp.ClientResponseError`
|
|
54
59
|
"""
|
|
60
|
+
|
|
61
|
+
if not aiohttp:
|
|
62
|
+
raise RuntimeError("aiohttp is not installed. Try pip install aiohttp")
|
|
63
|
+
|
|
55
64
|
async with aiohttp.ClientSession() as session:
|
|
56
65
|
async with session.get(url, **kwargs) as response:
|
|
57
66
|
if not ignore_status:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|