Skip to content

Commit

Permalink
Prepare release 0.3a1-2
Browse files Browse the repository at this point in the history
Drop Python 3.6 support
  • Loading branch information
zjkmxy committed Apr 30, 2021
1 parent 5244a8e commit 1fc074a
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 34 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ['3.6', '3.8', 'pypy3']
python-version: ['3.7', '3.9', 'pypy-3.7']

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
12 changes: 10 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
Changelog
=========

Master -- (latest)
++++++++++++++++++
0.3a1-2 (2021-04-29)
++++++++++++++++++++
* Handle ConnectionResetError.
* Drop Python 3.6 support.

0.3a1-1 (2021-01-31)
++++++++++++++++++++
* Transfer the repo to ``named-data/python-ndn``.
* Fix cocoapy to make it work on MacOS 11 Big Sur.
* Add more supports to NDNLPv2 (CongestionMark).
* Add dispatcher and set_interest_filter.

0.3a1 (2020-09-24)
++++++++++++++++++
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python-ndn

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

It supports Python >=3.6 and PyPy3 >=7.1.1.
It supports Python >=3.7 and PyPy3 >=7.1.1.

Please see our documentation_ if you have any issues.

Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Sphinx>=3.2.1
sphinx-rtd-theme>=0.5.0
sphinx-autodoc-typehints>=1.11.0
pycryptodomex>=3.8.2
pygtrie>=2.3.2
pycryptodomex>=3.10.1
pygtrie>=2.4.2
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
version = re.search(r'__version__ = "(.*?)"', f.read()).group(1)


requirements = ['pycryptodomex >= 3.9.9', 'pygtrie >= 2.3.3', 'dataclasses >= 0.6']
requirements = ['pycryptodomex >= 3.10.1', 'pygtrie >= 2.4.2']
setup(
name='python-ndn',
version=version,
Expand All @@ -35,7 +35,6 @@

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

'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
Expand All @@ -47,7 +46,7 @@
package_dir={'': 'src'},

install_requires=requirements,
python_requires=">=3.6",
python_requires=">=3.7",
extras_require={
"dev": ["pytest>=5.3.5", "pytest-cov>=2.8.1", "flake8>=3.7.9"],
}
Expand Down
2 changes: 1 addition & 1 deletion src/ndn/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3a1-1"
__version__ = "0.3a1-2"
36 changes: 18 additions & 18 deletions src/ndn/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def express_interest(self,
kwargs['nonce'] = gen_nonce()
interest_param = InterestParam.from_dict(kwargs)
interest, final_name = make_interest(name, interest_param, app_param, signer=signer, need_final_name=True)
future = aio.get_event_loop().create_future()
future = aio.get_running_loop().create_future()
node = self._int_tree.setdefault(final_name, InterestTreeNode())
node.append_interest(future, interest_param)
self.face.send(interest)
Expand All @@ -240,11 +240,13 @@ async def _wait_for_data(self, future: aio.Future, lifetime: int, name: FormalNa
else:
raise ValidationFailure(name, meta_info, content)

async def main_loop(self, after_start: Awaitable = None):
async def main_loop(self, after_start: Awaitable = None) -> bool:
"""
The main loop of NDNApp.
:param after_start: the coroutine to start after connection to NFD is established.
:return: ``True`` if the connection is shutdown not by ``Ctrl+C``.
For example, manually or by the other side.
"""
async def starting_task():
for name, route, validator, need_raw_packet, need_sig_ptrs in self._autoreg_routes:
Expand All @@ -265,12 +267,19 @@ async def starting_task():
elif isinstance(after_start, aio.Task) or isinstance(after_start, aio.Future):
after_start.cancel()
raise
task = aio.ensure_future(starting_task())
task = aio.create_task(starting_task())
logging.debug('Connected to NFD node, start running...')
await self.face.run()
self.face.shutdown()
try:
await self.face.run()
ret = True
except aio.CancelledError:
logging.info('Shutting down')
ret = False
finally:
self.face.shutdown()
self._clean_up()
await task
return ret

def _clean_up(self):
for node in self._int_tree.itervalues():
Expand All @@ -285,13 +294,11 @@ def shutdown(self):
logging.info('Manually shutdown')
self.face.shutdown()

def run_forever(self, after_start: Awaitable = None) -> bool:
def run_forever(self, after_start: Awaitable = None):
"""
A non-async wrapper of :meth:`main_loop`.
:param after_start: the coroutine to start after connection to NFD is established.
:return: ``True`` if the connection is shutdown not by ``Ctrl+C``.
For example, manually or by the other side.
:examples:
.. code-block:: python3
Expand All @@ -301,17 +308,10 @@ def run_forever(self, after_start: Awaitable = None) -> bool:
if __name__ == '__main__':
app.run_forever(after_start=main())
"""
task = self.main_loop(after_start)
try:
aio.get_event_loop().run_until_complete(task)
ret = True
aio.run(self.main_loop(after_start))
except KeyboardInterrupt:
logging.info('Receiving Ctrl+C, shutdown')
ret = False
finally:
self.face.shutdown()
logging.debug('Face is down now')
return ret
logging.info('Receiving Ctrl+C, exit')

def route(self, name: NonStrictName, validator: Optional[Validator] = None,
need_raw_packet: bool = False, need_sig_ptrs: bool = False):
Expand Down Expand Up @@ -355,7 +355,7 @@ def on_interest(name: FormalName, param: InterestParam, app_param):
def decorator(func: Route):
self._autoreg_routes.append((name, func, validator, need_raw_packet, need_sig_ptrs))
if self.face.running:
aio.ensure_future(self.register(name, func, validator, need_raw_packet, need_sig_ptrs))
aio.create_task(self.register(name, func, validator, need_raw_packet, need_sig_ptrs))
return func
return decorator

Expand Down
2 changes: 1 addition & 1 deletion src/ndn/schema/schema_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ async def _int_validator(self, name: FormalName, sig_ptrs: SignaturePtrs) -> boo
def _on_interest_root(self, name: FormalName, param: InterestParam,
app_param: Optional[BinaryStr], raw_packet: BinaryStr):
match = self.match(name)
aio.ensure_future(match.on_interest(param, app_param, raw_packet))
aio.create_task(match.on_interest(param, app_param, raw_packet))

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

Expand Down
2 changes: 1 addition & 1 deletion src/ndn/transport/stream_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def run(self):
siz = await read_tl_num_from_stream(self.reader, bio)
bio.write(await self.reader.readexactly(siz))
buf = bio.getvalue()
aio.ensure_future(self.callback(typ, buf))
aio.create_task(self.callback(typ, buf))
except (aio.IncompleteReadError, ConnectionResetError):
self.shutdown()

Expand Down
8 changes: 6 additions & 2 deletions tests/integration/app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ class NDNAppTestSuite:
app = None

def test_main(self):
aio.run(self.comain())

async def comain(self):
face = DummyFace(self.face_proc)
keychain = KeychainDigest()
self.app = NDNApp(face, keychain)
face.app = self.app
self.app.run_forever(after_start=self.app_main())
await self.app.main_loop(self.app_main())
# self.app.run_forever(after_start=self.app_main())

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

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

0 comments on commit 1fc074a

Please sign in to comment.