wepoll 0.2.0__tar.gz → 0.3.0__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. {wepoll-0.2.0 → wepoll-0.3.0}/PKG-INFO +1 -1
  2. {wepoll-0.2.0 → wepoll-0.3.0}/tests/test_wepoll_cyares.py +19 -17
  3. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/__init__.py +1 -1
  4. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/_wepoll.c +1119 -892
  5. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/_wepoll.pxd +2 -2
  6. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/_wepoll.pyx +46 -79
  7. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/flags.py +13 -0
  8. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/loop.py +1 -0
  9. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/selector.py +13 -19
  10. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll.egg-info/PKG-INFO +1 -1
  11. {wepoll-0.2.0 → wepoll-0.3.0}/MANIFEST.in +0 -0
  12. {wepoll-0.2.0 → wepoll-0.3.0}/README.md +0 -0
  13. {wepoll-0.2.0 → wepoll-0.3.0}/pyproject.toml +0 -0
  14. {wepoll-0.2.0 → wepoll-0.3.0}/setup.cfg +0 -0
  15. {wepoll-0.2.0 → wepoll-0.3.0}/setup.py +0 -0
  16. {wepoll-0.2.0 → wepoll-0.3.0}/tests/test_wepoll_eventloop.py +0 -0
  17. {wepoll-0.2.0 → wepoll-0.3.0}/tests/test_wepoll_selectors.py +0 -0
  18. {wepoll-0.2.0 → wepoll-0.3.0}/vendor/wepoll/wepoll.c +0 -0
  19. {wepoll-0.2.0 → wepoll-0.3.0}/vendor/wepoll/wepoll.h +0 -0
  20. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/__init__.pxd +0 -0
  21. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/_wepoll.pyi +0 -0
  22. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/msvc_compat.h +0 -0
  23. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/socket.pxd +0 -0
  24. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll.egg-info/SOURCES.txt +0 -0
  25. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll.egg-info/dependency_links.txt +0 -0
  26. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll.egg-info/not-zip-safe +0 -0
  27. {wepoll-0.2.0 → wepoll-0.3.0}/wepoll.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wepoll
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Cython adaptation of the wepoll C Library providing epoll selectors to windows
5
5
  Author-email: Vizonex <VizonexBusiness@gmail.com>
6
6
  License-Expression: MIT
@@ -1,12 +1,10 @@
1
1
  from wepoll import epoll, EPOLLIN, EPOLLOUT
2
- from socket import AF_INET
3
2
  import pytest
4
3
 
5
-
6
4
  cyares = pytest.importorskip("cyares")
7
5
  if cyares is not None:
8
6
  from cyares import Channel
9
- from cyares.channel import CYARES_SOCKET_BAD
7
+
10
8
  # based off pycares's testsuite
11
9
 
12
10
  READ = EPOLLIN
@@ -17,29 +15,33 @@ class TestCyaresWepoll:
17
15
 
18
16
  def wait(self):
19
17
  # The function were really testing is this wait function
20
- poll = epoll()
21
- while True:
22
- r, w = self.channel.getsock()
23
- if not r and not w:
24
- break
25
- for rs in r:
26
- poll.register(rs, EPOLLIN)
27
- for ws in w:
28
- poll.register(ws, EPOLLOUT)
29
18
 
19
+ while self.channel.running_queries:
30
20
  timeout = self.channel.timeout()
31
21
  if timeout == 0.0:
32
- self.channel.process_fd(CYARES_SOCKET_BAD, CYARES_SOCKET_BAD)
22
+ self.channel.process_no_fds()
33
23
  continue
34
- for fd, event in poll.poll(timeout):
24
+ for fd, event in self.poll.poll(timeout):
35
25
  if event & ~EPOLLIN:
36
26
  self.channel.process_write_fd(fd)
37
27
  if event & ~EPOLLOUT:
38
28
  self.channel.process_read_fd(fd)
39
29
 
30
+ def socket_state_cb(self, fd: int, r:bool, w: bool):
31
+ flags = 0
32
+ if r:
33
+ flags |= READ
34
+ if w:
35
+ flags |= WRITE
36
+
37
+ if flags:
38
+ self.poll.register(fd, flags)
39
+ else:
40
+ self.poll.unregister(fd)
41
+
40
42
  def test_resolve(self):
41
- self.channel = Channel(event_thread=False, servers=["8.8.8.8", "8.8.4.4"])
42
- fut = self.channel.gethostbyname("python.org", AF_INET)
43
+ self.poll = epoll()
44
+ self.channel = Channel(event_thread=False, servers=["8.8.8.8", "8.8.4.4"], sock_state_cb=self.socket_state_cb)
45
+ fut = self.channel.query("python.org", "A")
43
46
  self.wait()
44
- self.channel.cancel()
45
47
  assert fut.result()
@@ -15,7 +15,7 @@ from .loop import WepollEventLoop
15
15
  from .selector import EpollSelector
16
16
 
17
17
  __author__ = "Vizonex"
18
- __version__ = "0.2.0"
18
+ __version__ = "0.3.0"
19
19
  __all__ = (
20
20
  "EPOLLERR",
21
21
  "EPOLLHUP",