Skip to content

Commit 1fc074a

Browse files
committed
Prepare release 0.3a1-2
Drop Python 3.6 support
1 parent 5244a8e commit 1fc074a

File tree

10 files changed

+45
-34
lines changed

10 files changed

+45
-34
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ jobs:
99
strategy:
1010
max-parallel: 4
1111
matrix:
12-
python-version: ['3.6', '3.8', 'pypy3']
12+
python-version: ['3.7', '3.9', 'pypy-3.7']
1313

1414
steps:
15-
- uses: actions/checkout@v1
15+
- uses: actions/checkout@v2
1616
- name: Set up Python ${{ matrix.python-version }}
17-
uses: actions/setup-python@v1
17+
uses: actions/setup-python@v2
1818
with:
1919
python-version: ${{ matrix.python-version }}
2020
- name: Install dependencies

CHANGELOG.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
Changelog
22
=========
33

4-
Master -- (latest)
5-
++++++++++++++++++
4+
0.3a1-2 (2021-04-29)
5+
++++++++++++++++++++
6+
* Handle ConnectionResetError.
7+
* Drop Python 3.6 support.
8+
9+
0.3a1-1 (2021-01-31)
10+
++++++++++++++++++++
611
* Transfer the repo to ``named-data/python-ndn``.
12+
* Fix cocoapy to make it work on MacOS 11 Big Sur.
13+
* Add more supports to NDNLPv2 (CongestionMark).
14+
* Add dispatcher and set_interest_filter.
715

816
0.3a1 (2020-09-24)
917
++++++++++++++++++

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ python-ndn
88

99
A Named Data Networking client library with AsyncIO support in Python 3.
1010

11-
It supports Python >=3.6 and PyPy3 >=7.1.1.
11+
It supports Python >=3.7 and PyPy3 >=7.1.1.
1212

1313
Please see our documentation_ if you have any issues.
1414

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Sphinx>=3.2.1
22
sphinx-rtd-theme>=0.5.0
33
sphinx-autodoc-typehints>=1.11.0
4-
pycryptodomex>=3.8.2
5-
pygtrie>=2.3.2
4+
pycryptodomex>=3.10.1
5+
pygtrie>=2.4.2

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
version = re.search(r'__version__ = "(.*?)"', f.read()).group(1)
1010

1111

12-
requirements = ['pycryptodomex >= 3.9.9', 'pygtrie >= 2.3.3', 'dataclasses >= 0.6']
12+
requirements = ['pycryptodomex >= 3.10.1', 'pygtrie >= 2.4.2']
1313
setup(
1414
name='python-ndn',
1515
version=version,
@@ -35,7 +35,6 @@
3535

3636
'License :: OSI Approved :: Apache Software License',
3737

38-
'Programming Language :: Python :: 3.6',
3938
'Programming Language :: Python :: 3.7',
4039
'Programming Language :: Python :: 3.8',
4140
'Programming Language :: Python :: 3.9',
@@ -47,7 +46,7 @@
4746
package_dir={'': 'src'},
4847

4948
install_requires=requirements,
50-
python_requires=">=3.6",
49+
python_requires=">=3.7",
5150
extras_require={
5251
"dev": ["pytest>=5.3.5", "pytest-cov>=2.8.1", "flake8>=3.7.9"],
5352
}

src/ndn/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3a1-1"
1+
__version__ = "0.3a1-2"

src/ndn/app.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def express_interest(self,
213213
kwargs['nonce'] = gen_nonce()
214214
interest_param = InterestParam.from_dict(kwargs)
215215
interest, final_name = make_interest(name, interest_param, app_param, signer=signer, need_final_name=True)
216-
future = aio.get_event_loop().create_future()
216+
future = aio.get_running_loop().create_future()
217217
node = self._int_tree.setdefault(final_name, InterestTreeNode())
218218
node.append_interest(future, interest_param)
219219
self.face.send(interest)
@@ -240,11 +240,13 @@ async def _wait_for_data(self, future: aio.Future, lifetime: int, name: FormalNa
240240
else:
241241
raise ValidationFailure(name, meta_info, content)
242242

243-
async def main_loop(self, after_start: Awaitable = None):
243+
async def main_loop(self, after_start: Awaitable = None) -> bool:
244244
"""
245245
The main loop of NDNApp.
246246
247247
:param after_start: the coroutine to start after connection to NFD is established.
248+
:return: ``True`` if the connection is shutdown not by ``Ctrl+C``.
249+
For example, manually or by the other side.
248250
"""
249251
async def starting_task():
250252
for name, route, validator, need_raw_packet, need_sig_ptrs in self._autoreg_routes:
@@ -265,12 +267,19 @@ async def starting_task():
265267
elif isinstance(after_start, aio.Task) or isinstance(after_start, aio.Future):
266268
after_start.cancel()
267269
raise
268-
task = aio.ensure_future(starting_task())
270+
task = aio.create_task(starting_task())
269271
logging.debug('Connected to NFD node, start running...')
270-
await self.face.run()
271-
self.face.shutdown()
272+
try:
273+
await self.face.run()
274+
ret = True
275+
except aio.CancelledError:
276+
logging.info('Shutting down')
277+
ret = False
278+
finally:
279+
self.face.shutdown()
272280
self._clean_up()
273281
await task
282+
return ret
274283

275284
def _clean_up(self):
276285
for node in self._int_tree.itervalues():
@@ -285,13 +294,11 @@ def shutdown(self):
285294
logging.info('Manually shutdown')
286295
self.face.shutdown()
287296

288-
def run_forever(self, after_start: Awaitable = None) -> bool:
297+
def run_forever(self, after_start: Awaitable = None):
289298
"""
290299
A non-async wrapper of :meth:`main_loop`.
291300
292301
:param after_start: the coroutine to start after connection to NFD is established.
293-
:return: ``True`` if the connection is shutdown not by ``Ctrl+C``.
294-
For example, manually or by the other side.
295302
296303
:examples:
297304
.. code-block:: python3
@@ -301,17 +308,10 @@ def run_forever(self, after_start: Awaitable = None) -> bool:
301308
if __name__ == '__main__':
302309
app.run_forever(after_start=main())
303310
"""
304-
task = self.main_loop(after_start)
305311
try:
306-
aio.get_event_loop().run_until_complete(task)
307-
ret = True
312+
aio.run(self.main_loop(after_start))
308313
except KeyboardInterrupt:
309-
logging.info('Receiving Ctrl+C, shutdown')
310-
ret = False
311-
finally:
312-
self.face.shutdown()
313-
logging.debug('Face is down now')
314-
return ret
314+
logging.info('Receiving Ctrl+C, exit')
315315

316316
def route(self, name: NonStrictName, validator: Optional[Validator] = None,
317317
need_raw_packet: bool = False, need_sig_ptrs: bool = False):
@@ -355,7 +355,7 @@ def on_interest(name: FormalName, param: InterestParam, app_param):
355355
def decorator(func: Route):
356356
self._autoreg_routes.append((name, func, validator, need_raw_packet, need_sig_ptrs))
357357
if self.face.running:
358-
aio.ensure_future(self.register(name, func, validator, need_raw_packet, need_sig_ptrs))
358+
aio.create_task(self.register(name, func, validator, need_raw_packet, need_sig_ptrs))
359359
return func
360360
return decorator
361361

src/ndn/schema/schema_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ async def _int_validator(self, name: FormalName, sig_ptrs: SignaturePtrs) -> boo
285285
def _on_interest_root(self, name: FormalName, param: InterestParam,
286286
app_param: Optional[BinaryStr], raw_packet: BinaryStr):
287287
match = self.match(name)
288-
aio.ensure_future(match.on_interest(param, app_param, raw_packet))
288+
aio.create_task(match.on_interest(param, app_param, raw_packet))
289289

290290
# ====== Functions on Interest & Data processing (For overriding) ======
291291

src/ndn/transport/stream_socket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async def run(self):
6464
siz = await read_tl_num_from_stream(self.reader, bio)
6565
bio.write(await self.reader.readexactly(siz))
6666
buf = bio.getvalue()
67-
aio.ensure_future(self.callback(typ, buf))
67+
aio.create_task(self.callback(typ, buf))
6868
except (aio.IncompleteReadError, ConnectionResetError):
6969
self.shutdown()
7070

tests/integration/app_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ class NDNAppTestSuite:
2929
app = None
3030

3131
def test_main(self):
32+
aio.run(self.comain())
33+
34+
async def comain(self):
3235
face = DummyFace(self.face_proc)
3336
keychain = KeychainDigest()
3437
self.app = NDNApp(face, keychain)
3538
face.app = self.app
36-
self.app.run_forever(after_start=self.app_main())
39+
await self.app.main_loop(self.app_main())
40+
# self.app.run_forever(after_start=self.app_main())
3741

3842
@abc.abstractmethod
3943
async def face_proc(self, face: DummyFace):
@@ -118,7 +122,7 @@ async def face_proc(self, face: DummyFace):
118122
b'\x05\x0c\x07\x05\x08\x03not\x21\x00\x0c\x01\x05'
119123
b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\x05')
120124
await face.input_packet(b'\x06\x1d\x07\x10\x08\x03not\x08\timportant\x14\x03\x18\x01\x00\x15\x04test')
121-
await aio.sleep(0.007)
125+
await aio.sleep(0.1)
122126

123127
async def app_main(self):
124128
future1 = self.app.express_interest('/not', nonce=None, lifetime=5, can_be_prefix=False)

0 commit comments

Comments
 (0)