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.
- {wepoll-0.2.0 → wepoll-0.3.0}/PKG-INFO +1 -1
- {wepoll-0.2.0 → wepoll-0.3.0}/tests/test_wepoll_cyares.py +19 -17
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/__init__.py +1 -1
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/_wepoll.c +1119 -892
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/_wepoll.pxd +2 -2
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/_wepoll.pyx +46 -79
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/flags.py +13 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/loop.py +1 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/selector.py +13 -19
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll.egg-info/PKG-INFO +1 -1
- {wepoll-0.2.0 → wepoll-0.3.0}/MANIFEST.in +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/README.md +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/pyproject.toml +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/setup.cfg +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/setup.py +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/tests/test_wepoll_eventloop.py +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/tests/test_wepoll_selectors.py +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/vendor/wepoll/wepoll.c +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/vendor/wepoll/wepoll.h +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/__init__.pxd +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/_wepoll.pyi +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/msvc_compat.h +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll/socket.pxd +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll.egg-info/SOURCES.txt +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll.egg-info/dependency_links.txt +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll.egg-info/not-zip-safe +0 -0
- {wepoll-0.2.0 → wepoll-0.3.0}/wepoll.egg-info/top_level.txt +0 -0
|
@@ -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
|
-
|
|
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.
|
|
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.
|
|
42
|
-
|
|
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()
|