winloop 0.1.2__tar.gz → 0.1.3__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.
Files changed (27) hide show
  1. {winloop-0.1.2/winloop.egg-info → winloop-0.1.3}/PKG-INFO +19 -8
  2. {winloop-0.1.2 → winloop-0.1.3}/README.md +18 -7
  3. {winloop-0.1.2 → winloop-0.1.3}/setup.py +11 -2
  4. winloop-0.1.3/tests/test_aiodns.py +41 -0
  5. winloop-0.1.3/tests/test_cython.py +32 -0
  6. winloop-0.1.3/tests/test_executors.py +43 -0
  7. {winloop-0.1.2 → winloop-0.1.3}/winloop/__init__.py +3 -17
  8. {winloop-0.1.2 → winloop-0.1.3}/winloop/_testbase.py +1 -1
  9. winloop-0.1.3/winloop/_version.py +13 -0
  10. {winloop-0.1.2 → winloop-0.1.3}/winloop/loop.c +7402 -7467
  11. {winloop-0.1.2 → winloop-0.1.3/winloop.egg-info}/PKG-INFO +19 -8
  12. {winloop-0.1.2 → winloop-0.1.3}/winloop.egg-info/SOURCES.txt +4 -0
  13. {winloop-0.1.2 → winloop-0.1.3}/LICENSE-APACHE +0 -0
  14. {winloop-0.1.2 → winloop-0.1.3}/LICENSE-MIT +0 -0
  15. {winloop-0.1.2 → winloop-0.1.3}/pyproject.toml +0 -0
  16. {winloop-0.1.2 → winloop-0.1.3}/setup.cfg +0 -0
  17. {winloop-0.1.2 → winloop-0.1.3}/tests/__init__.py +0 -0
  18. {winloop-0.1.2 → winloop-0.1.3}/tests/__main__.py +0 -0
  19. {winloop-0.1.2 → winloop-0.1.3}/tests/test_aiohttp.py +0 -0
  20. {winloop-0.1.2 → winloop-0.1.3}/tests/test_aiomultiprocess.py +0 -0
  21. {winloop-0.1.2 → winloop-0.1.3}/winloop/_noop.py +0 -0
  22. {winloop-0.1.2 → winloop-0.1.3}/winloop/includes/__init__.py +0 -0
  23. {winloop-0.1.2 → winloop-0.1.3}/winloop/includes/context.h +0 -0
  24. {winloop-0.1.2 → winloop-0.1.3}/winloop/loop.pyi +0 -0
  25. {winloop-0.1.2 → winloop-0.1.3}/winloop.egg-info/dependency_links.txt +0 -0
  26. {winloop-0.1.2 → winloop-0.1.3}/winloop.egg-info/requires.txt +0 -0
  27. {winloop-0.1.2 → winloop-0.1.3}/winloop.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: winloop
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: An alternative library for uvloop compatibility with Windows
5
5
  Author: Vizonex
6
6
  License: MIT
@@ -17,6 +17,7 @@ License-File: LICENSE-MIT
17
17
  Requires-Dist: cython
18
18
 
19
19
  <img src="https://raw.githubusercontent.com/Vizonex/Winloop/main/winloop.png" width="200px"/>
20
+ <a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
20
21
 
21
22
  # Winloop
22
23
  An Alternative library for uvloop compatability with windows because let's face it. Window's python asyncio standard libaray is garabage escpecially when Windows Defender decides to eat half your ram.
@@ -46,6 +47,11 @@ python setup.py build_ext --inplace
46
47
 
47
48
  If you find any bugs with this library be sure to open up an issue to our github repo. Me and other contributors will be happy try to help you figure out and diagnose your problems.
48
49
 
50
+ ## Making pull requests
51
+ We encourage anyone to make pull-requests to winloop from spelling mistakes to vulnerability patches. Every little bit helps keep this library maintained and alive.
52
+ Make sure that you are able to compile the library with the steps shown above. We plan to implement a nightly workflow to verify one's pull request in the future.
53
+
54
+
49
55
 
50
56
 
51
57
  ```python
@@ -255,24 +261,29 @@ if __name__ == "__main__":
255
261
  ```
256
262
 
257
263
 
258
- ## Possible Upcomming Features/Optimizations to Winloop / This is also our TODO list
259
- I have been looking deeply into some of the proposed Pulls and changes to `Uvloop` and I will be tuning in and listening to what's going on uvloop's end to see what we might have to change . This is a list of features I would like to implement from likely to least likely to be done as well as solved. If any of these feature have been added you will simply know by the fact that It won't be on this list anymore...
264
+ ## TODO-List
260
265
 
261
- - Nightly Builds And Test Suite Workflows for anyone wanting to use newer unreleased versions.
266
+ - Update Fastapi Example to a more recent version of fastapi
262
267
 
263
- - Format all `.py` & `.pyi` files using [black](https://pypi.org/project/black/)
268
+ - Contact uvicorn about this [issue](https://github.com/Vizonex/Winloop/issues/11) I have a funny feeling something is going on here...
264
269
 
265
- - Finish implementing our brand new test suite and write a workflow for using it whenever a pullrequest is being made
270
+ - Nightly Builds And Test Suite Workflows for anyone wanting to use newer unreleased versions.
266
271
 
267
272
  - Drop All `DEF` Macros, I'm currently seeking help on replacements for macros where all the variables are known about at compile-time
268
273
 
269
274
  - Adding in the nessesary hooks for pyinstaller to compile this fast library to executable code even though hooks have been known to inflate the size of the `.exe` files. This is because calling hidden-imports for all the `__init__.py` modules might annoy some developers. (Luckily I'm aware of this issue because I've been doing this myself...)
270
275
 
271
- - drop the `.lib` file for compiling libuv in replacement for libuv's C files directly once the current compiling problems and errors have been solved.
276
+ - write a workflow for compiling libuv on different versions of windows when distributing out pypi wheels.
277
+
278
+ - write a workflow for nightly builds if nessesary for verification of pull requests.
272
279
 
273
- - Sphinx Styled Documentation (Maybe I am thinking about it...)
280
+ - Sphinx Styled Documentation (Maybe I'm thinking about it...)
274
281
 
282
+ - Update benchmarks (They are old) can't belive I maintained this project for over a year now...
275
283
 
276
284
  ## Videos
277
285
  - By me: https://www.youtube.com/watch?v=tz9RYJ6aBZ8 (I might make a tutorial on how to use and install winloop it for those who have reading problems)
278
286
  - My Presentation and Virtual Confrence: https://www.youtube.com/watch?v=Cbb6trkKWXY
287
+
288
+ ## Contributing
289
+ I put my heart and soul into this library ever since it began and any help is apperciated and means a lot to me.
@@ -1,4 +1,5 @@
1
1
  <img src="https://raw.githubusercontent.com/Vizonex/Winloop/main/winloop.png" width="200px"/>
2
+ <a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
2
3
 
3
4
  # Winloop
4
5
  An Alternative library for uvloop compatability with windows because let's face it. Window's python asyncio standard libaray is garabage escpecially when Windows Defender decides to eat half your ram.
@@ -28,6 +29,11 @@ python setup.py build_ext --inplace
28
29
 
29
30
  If you find any bugs with this library be sure to open up an issue to our github repo. Me and other contributors will be happy try to help you figure out and diagnose your problems.
30
31
 
32
+ ## Making pull requests
33
+ We encourage anyone to make pull-requests to winloop from spelling mistakes to vulnerability patches. Every little bit helps keep this library maintained and alive.
34
+ Make sure that you are able to compile the library with the steps shown above. We plan to implement a nightly workflow to verify one's pull request in the future.
35
+
36
+
31
37
 
32
38
 
33
39
  ```python
@@ -237,24 +243,29 @@ if __name__ == "__main__":
237
243
  ```
238
244
 
239
245
 
240
- ## Possible Upcomming Features/Optimizations to Winloop / This is also our TODO list
241
- I have been looking deeply into some of the proposed Pulls and changes to `Uvloop` and I will be tuning in and listening to what's going on uvloop's end to see what we might have to change . This is a list of features I would like to implement from likely to least likely to be done as well as solved. If any of these feature have been added you will simply know by the fact that It won't be on this list anymore...
246
+ ## TODO-List
242
247
 
243
- - Nightly Builds And Test Suite Workflows for anyone wanting to use newer unreleased versions.
248
+ - Update Fastapi Example to a more recent version of fastapi
244
249
 
245
- - Format all `.py` & `.pyi` files using [black](https://pypi.org/project/black/)
250
+ - Contact uvicorn about this [issue](https://github.com/Vizonex/Winloop/issues/11) I have a funny feeling something is going on here...
246
251
 
247
- - Finish implementing our brand new test suite and write a workflow for using it whenever a pullrequest is being made
252
+ - Nightly Builds And Test Suite Workflows for anyone wanting to use newer unreleased versions.
248
253
 
249
254
  - Drop All `DEF` Macros, I'm currently seeking help on replacements for macros where all the variables are known about at compile-time
250
255
 
251
256
  - Adding in the nessesary hooks for pyinstaller to compile this fast library to executable code even though hooks have been known to inflate the size of the `.exe` files. This is because calling hidden-imports for all the `__init__.py` modules might annoy some developers. (Luckily I'm aware of this issue because I've been doing this myself...)
252
257
 
253
- - drop the `.lib` file for compiling libuv in replacement for libuv's C files directly once the current compiling problems and errors have been solved.
258
+ - write a workflow for compiling libuv on different versions of windows when distributing out pypi wheels.
259
+
260
+ - write a workflow for nightly builds if nessesary for verification of pull requests.
254
261
 
255
- - Sphinx Styled Documentation (Maybe I am thinking about it...)
262
+ - Sphinx Styled Documentation (Maybe I'm thinking about it...)
256
263
 
264
+ - Update benchmarks (They are old) can't belive I maintained this project for over a year now...
257
265
 
258
266
  ## Videos
259
267
  - By me: https://www.youtube.com/watch?v=tz9RYJ6aBZ8 (I might make a tutorial on how to use and install winloop it for those who have reading problems)
260
268
  - My Presentation and Virtual Confrence: https://www.youtube.com/watch?v=Cbb6trkKWXY
269
+
270
+ ## Contributing
271
+ I put my heart and soul into this library ever since it began and any help is apperciated and means a lot to me.
@@ -7,9 +7,18 @@ from Cython.Build import cythonize
7
7
 
8
8
 
9
9
  HERE = pathlib.Path("winloop")
10
+ _ROOT = pathlib.Path(__file__).parent
10
11
 
11
- __version__ = "0.1.2"
12
12
 
13
+ with open(str(_ROOT / 'winloop' / '_version.py')) as f:
14
+ for line in f:
15
+ if line.startswith('__version__ ='):
16
+ _, _, version = line.partition('=')
17
+ VERSION = version.strip(" \n'\"")
18
+ break
19
+ else:
20
+ raise RuntimeError(
21
+ 'unable to read the version from winloop/_version.py')
13
22
 
14
23
 
15
24
  # This is a temporary test Solution and is not the official file yet but this is to display/show what
@@ -54,7 +63,7 @@ def do_installation():
54
63
  setup(
55
64
  name="winloop",
56
65
  author="Vizonex",
57
- version=__version__,
66
+ version=VERSION,
58
67
  description="""An alternative library for uvloop compatibility with Windows""",
59
68
  ext_modules=cythonize(ext),
60
69
  license="MIT",
@@ -0,0 +1,41 @@
1
+ # NOTE: I forked the aiodns Repository you will have to use that for now
2
+ # or wait for the pull request I recently made to go through: https://github.com/saghul/aiodns/pull/116
3
+
4
+ try:
5
+ import aiodns
6
+ except ImportError:
7
+ skip_tests = True
8
+ else:
9
+ skip_tests = False
10
+
11
+ import asyncio
12
+ import sys
13
+ import unittest
14
+ import weakref
15
+
16
+ from winloop import _testbase as tb
17
+
18
+
19
+ class _TestAiodns:
20
+ def test_dns_query(self):
21
+ # This is not allowed to fail...
22
+ resolver = aiodns.DNSResolver(loop=self.loop)
23
+
24
+ async def test():
25
+ async def query(name, query_type):
26
+ return await resolver.query(name, query_type)
27
+ await query('google.com', 'A')
28
+ await query('httpbin.org', 'A')
29
+ await query('example.com', 'A')
30
+
31
+ self.loop.run_until_complete(test())
32
+
33
+
34
+ @unittest.skipIf(skip_tests, "no aiodns module")
35
+ class Test_UV_Aiodns(_TestAiodns, tb.UVTestCase):
36
+ pass
37
+
38
+
39
+ @unittest.skip("aiodns needs a SelectorEventLoop on Windows. See more: https://github.com/saghul/aiodns/issues/86")
40
+ class Test_AIO_Aiodns(_TestAiodns, tb.AIOTestCase):
41
+ pass
@@ -0,0 +1,32 @@
1
+ import asyncio
2
+ from winloop._testbase import UVTestCase
3
+
4
+ class TestCythonIntegration(UVTestCase):
5
+ def test_cython_coro_is_coroutine(self):
6
+ from winloop.loop import _test_coroutine_1
7
+ from asyncio.coroutines import _format_coroutine
8
+
9
+ coro = _test_coroutine_1()
10
+
11
+ coro_fmt = _format_coroutine(coro)
12
+ self.assertTrue(
13
+ coro_fmt.startswith("_test_coroutine_1() done")
14
+ or coro_fmt.startswith("_test_coroutine_1() running")
15
+ )
16
+ self.assertEqual(_test_coroutine_1.__qualname__, "_test_coroutine_1")
17
+ self.assertEqual(_test_coroutine_1.__name__, "_test_coroutine_1")
18
+ self.assertTrue(asyncio.iscoroutine(coro))
19
+ fut = asyncio.ensure_future(coro)
20
+ self.assertTrue(isinstance(fut, asyncio.Future))
21
+ self.assertTrue(isinstance(fut, asyncio.Task))
22
+ fut.cancel()
23
+
24
+ with self.assertRaises(asyncio.CancelledError):
25
+ self.loop.run_until_complete(fut)
26
+
27
+ try:
28
+ _format_coroutine(coro) # This line checks against Cython segfault
29
+ except TypeError:
30
+ # TODO: Fix Cython to not reset __name__/__qualname__ to None
31
+ pass
32
+ coro.close()
@@ -0,0 +1,43 @@
1
+ import asyncio
2
+ import concurrent.futures
3
+ import multiprocessing
4
+ import unittest
5
+
6
+ from winloop import _testbase as tb
7
+
8
+
9
+ def fib(n):
10
+ if n < 2:
11
+ return 1
12
+ return fib(n - 2) + fib(n - 1)
13
+
14
+
15
+ class _TestExecutors:
16
+ def run_pool_test(self, pool_factory):
17
+ async def run():
18
+ pool = pool_factory()
19
+ with pool:
20
+ coros = []
21
+ for i in range(0, 10):
22
+ coros.append(self.loop.run_in_executor(pool, fib, i))
23
+ res = await asyncio.gather(*coros)
24
+ self.assertEqual(res, fib10)
25
+ await asyncio.sleep(0.01)
26
+
27
+ fib10 = [fib(i) for i in range(10)]
28
+ self.loop.run_until_complete(run())
29
+
30
+ # Proccess Pool Works just fine...
31
+ def test_executors_process_pool_01(self):
32
+ self.run_pool_test(concurrent.futures.ProcessPoolExecutor)
33
+
34
+ def test_executors_process_pool_02(self):
35
+ self.run_pool_test(concurrent.futures.ThreadPoolExecutor)
36
+
37
+
38
+ class TestUVExecutors(_TestExecutors, tb.UVTestCase):
39
+ pass
40
+
41
+
42
+ class TestAIOExecutors(_TestExecutors, tb.AIOTestCase):
43
+ pass
@@ -18,11 +18,10 @@ from asyncio.events import BaseDefaultEventLoopPolicy as __BasePolicy
18
18
 
19
19
  # from . import includes as __includes # NOQA
20
20
  from .loop import Loop as __BaseLoop # NOQA
21
+ from ._version import __version__ # NOQA
21
22
 
22
- # from ._version import __version__ # NOQA
23
23
 
24
-
25
- __all__ = ("new_event_loop", "install", "WinLoopPolicy")
24
+ __all__ = ("new_event_loop", "install", "EventLoopPolicy")
26
25
 
27
26
 
28
27
  class Loop(__BaseLoop, __asyncio.AbstractEventLoop): # type: ignore[misc]
@@ -47,7 +46,7 @@ def install() -> None:
47
46
  DeprecationWarning,
48
47
  stacklevel=1,
49
48
  )
50
- __asyncio.set_event_loop_policy(WinLoopPolicy())
49
+ __asyncio.set_event_loop_policy(EventLoopPolicy())
51
50
 
52
51
 
53
52
  # Copied from uvloop for the sake of compatability
@@ -174,16 +173,3 @@ class EventLoopPolicy(__BasePolicy):
174
173
 
175
174
  def set_child_watcher(self, watcher: _typing.Any) -> _typing.NoReturn:
176
175
  ...
177
-
178
-
179
- # For Easier Compatabilty with uvloop , WinLoopPolicy was chosen more as a vanity name
180
- # We will retain this name for now as backwards compatability but it will be removed
181
- # in the future in 0.1.3... - Vizonex
182
-
183
-
184
- class WinLoopPolicy(EventLoopPolicy):
185
- def __init__(self) -> None:
186
- _warnings.warn(
187
- "WinLoopPolicy is Deprecated and Will be removed in version 0.1.3"
188
- )
189
- super().__init__()
@@ -301,7 +301,7 @@ class UVTestCase(BaseTestCase):
301
301
  return winloop.new_event_loop()
302
302
 
303
303
  def new_policy(self):
304
- return winloop.WinLoopPolicy()
304
+ return winloop.EventLoopPolicy()
305
305
 
306
306
 
307
307
  class AIOTestCase(BaseTestCase):
@@ -0,0 +1,13 @@
1
+ # This file MUST NOT contain anything but the __version__ assignment.
2
+ #
3
+ # When making a release, change the value of __version__
4
+ # to an appropriate value, and open a pull request against
5
+ # the correct branch (master if making a new feature release).
6
+ # The commit message MUST contain a properly formatted release
7
+ # log, and the commit must be signed.
8
+ #
9
+ # The release automation will: build and test the packages for the
10
+ # supported platforms, publish the packages on PyPI, merge the PR
11
+ # to the target branch, create a Git tag pointing to the commit.
12
+
13
+ __version__ = '0.1.3'