Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.12.0 #94

Merged
merged 37 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cab2ea5
remove wrap_generator, deprecated since 0.10.0
shamrin Dec 31, 2020
cbbb309
remove run_iterator, deprecated since 0.10.0
shamrin Dec 31, 2020
4d414a9
remove trio2aio, deprecated since 0.10.0
shamrin Dec 31, 2020
dee471c
remove aio2trio, deprecated since 0.10.0
shamrin Dec 31, 2020
cdd808f
remove run_future and TrioEventLoop.run_future, deprecated since 0.10.0
shamrin Dec 31, 2020
1e9ef9e
remove unused imports in _adapter
shamrin Dec 31, 2020
e01154a
remove run_coroutine and TrioEventLoop.run_coroutine, deprecated sinc…
shamrin Dec 31, 2020
a42b2c1
remove unused import in test_thread
shamrin Dec 31, 2020
f2ebc0a
remove wrap_trio_context, deprecated since 0.10.0
shamrin Dec 31, 2020
518c29e
remove TrioEventLoop.run_trio, deprecated since 0.10.0
shamrin Dec 31, 2020
64366e7
remove run_asyncio and TrioEventLoop.run_asyncio, deprecated since 0.…
shamrin Jan 1, 2021
a61411c
remove unused imports in test_misc, test_adapter, test_callback
shamrin Jan 1, 2021
d0bc23e
temporarily disable flaky test_cancel_loop
shamrin Jan 1, 2021
3cffc2a
remove unused imports in _base, _loop
shamrin Jan 1, 2021
1c22295
configure towncrier to show Miscellaneous content
shamrin Jan 1, 2021
f1f62c2
mention that trio.hazmat TrioDeprecationWarning is gone now
shamrin Jan 1, 2021
ba572d6
0.12.0 version
shamrin Jan 1, 2021
050fb3d
0.12.0 history
shamrin Jan 1, 2021
4465d26
synchronize docstring: use recommended replacement for loop.run_trio
shamrin Jan 1, 2021
898a2a4
remove poetry section
shamrin Jan 1, 2021
9a9f357
mention issue #95 in xfail'ed test_cancel_loop
shamrin Jan 1, 2021
e775879
Python 3.10 drops the "loop" argument from "sleep"
smurfix Jan 2, 2021
4476608
Minimal de-`loop=loop`-ification
smurfix Jan 2, 2021
b6f2c67
port test_deprecate from Trio
shamrin Jan 3, 2021
40fba89
coverage: test no __await__ attribute case in Asyncio_Trio_Wrapper.__…
shamrin Jan 3, 2021
917b4fe
coverage: test not Future case in allow_asyncio
shamrin Jan 3, 2021
a965a61
coverage: test allow_asyncio(get_future_instance, ...)
shamrin Jan 3, 2021
5ca079a
consistent history headings; fix towncrier config to match
shamrin Jan 4, 2021
c414430
correct issue link in history
shamrin Jan 4, 2021
3fb7a07
clarify migration from removed API
shamrin Jan 4, 2021
950b0eb
Merge branch 'master' into release-0.12.0
oremanj Jan 6, 2021
c9b7bde
enable previously disabled test (at d0bc23e1ac68fda66f6848ecd6efeec60…
shamrin Jan 6, 2021
0b7f978
rename test
shamrin Jan 6, 2021
520768e
Merge branch 'master' into release-0.12.0
oremanj Jan 7, 2021
5006bee
merge recent newsfragments
shamrin Jan 7, 2021
970d81c
stop test_cancel_sleep from deadlocking and less dependent on timer
shamrin Jan 8, 2021
a18c2b4
version +dev
shamrin Jan 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions docs/source/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,50 @@ Release history

.. towncrier release notes start

trio-asyncio 0.12.0 (2021-01-04)
--------------------------------

Bugfixes
~~~~~~~~

- On Python versions with native contextvars support (3.7+), a Trio task
started from asyncio context (using :func:`trio_as_aio`,
:meth:`~BaseTrioEventLoop.trio_as_future`, etc) will now properly
inherit the contextvars of its caller. Also, if the entire
trio-asyncio loop is cancelled, such tasks will no longer let
`trio.Cancelled` exceptions leak into their asyncio caller. (`#76 <https://github.com/python-trio/trio-asyncio/issues/76>`__)
- Previously, cancelling the context surrounding an :func:`open_loop`
block might cause a deadlock in some cases. The ordering of operations
during loop teardown has been improved, so this shouldn't happen
anymore. (`#81 <https://github.com/python-trio/trio-asyncio/issues/81>`__)

Deprecations and Removals
~~~~~~~~~~~~~~~~~~~~~~~~~

A number of functions deprecated since 0.10.0 are now removed:

================================================= =============================================
Removed Replacement
================================================= =============================================
``wrap_generator(proc, *args)`` :func:`aio_as_trio(proc(*args))<aio_as_trio>`
``run_iterator(aiter)`` :func:`aio_as_trio(aiter)<aio_as_trio>`
``trio2aio`` :func:`aio_as_trio`
``aio2trio`` :func:`trio_as_aio`
``run_future`` ``TrioEventLoop.run_future`` :func:`run_aio_future`
``run_coroutine`` ``TrioEventLoop.run_coroutine`` :func:`run_aio_coroutine`
``wrap_trio_context(ctx)`` :func:`trio_as_aio(ctx)<trio_as_aio>`
``TrioEventLoop.run_trio(proc, *args)`` :func:`trio_as_aio(proc)(*args)<trio_as_aio>`
``run_asyncio(proc, *args)`` :func:`aio_as_trio(proc)(*args)<aio_as_trio>`
================================================= =============================================

Miscellaneous
~~~~~~~~~~~~~

- ``trio-asyncio`` now requires Trio 0.15. Support for Python < 3.6 has been removed. (`#82 <https://github.com/python-trio/trio-asyncio/issues/82>`__)

- No more ``TrioDeprecationWarning`` about ``trio.hazmat``. (`#82 <https://github.com/python-trio/trio-asyncio/issues/82>`__)


trio-asyncio 0.11.0 (2020-03-09)
--------------------------------

Expand Down
6 changes: 0 additions & 6 deletions newsfragments/76.bugfix.rst

This file was deleted.

4 changes: 0 additions & 4 deletions newsfragments/80.bugfix.rst

This file was deleted.

3 changes: 0 additions & 3 deletions newsfragments/82.misc.rst

This file was deleted.

26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
[tool.towncrier]
package = "trio_asyncio"
title_format = "trio-asyncio {version} ({project_date})"
filename = "docs/source/history.rst"
directory = "newsfragments"
underlines = ["-", "~", "^"]
issue_format = "`#{issue} <https://github.com/python-trio/trio-asyncio/issues/{issue}>`__"

[[tool.towncrier.type]]
directory = "feature"
name = "Features"
showcontent = true

[[tool.towncrier.type]]
directory = "bugfix"
name = "Bugfixes"
showcontent = true

[[tool.towncrier.type]]
directory = "doc"
name = "Improved documentation"
showcontent = true

[[tool.towncrier.type]]
directory = "removal"
name = "Deprecations and removals"
showcontent = true

[[tool.towncrier.type]]
directory = "misc"
name = "Miscellaneous"
showcontent = true
Copy link
Contributor Author

@shamrin shamrin Jan 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The showcontent = true line above is the whole reason for changing towncrier config. Otherwise, misc notes are missing their content in history.rst. I did it the same way as in trio: https://github.com/python-trio/trio/blob/master/pyproject.toml

8 changes: 0 additions & 8 deletions tests/aiotest/test_callback.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from tests import aiotest
import signal
import pytest
from .. import utils as test_utils


class TestCallback(aiotest.TestCase):
Expand Down Expand Up @@ -51,10 +50,6 @@ async def test():
func = lambda: False
coro = test()
try:
# no longer depends on the loop
# with pytest.raises(RuntimeError):
# fut = config.asyncio.Future(loop=loop)
# await loop.run_future(fut)
with pytest.raises(RuntimeError, match='not a sync loop'):
loop.run_until_complete(None)
with pytest.raises(RuntimeError):
Expand All @@ -71,9 +66,6 @@ async def test():
loop.run_in_executor(None, func)
with pytest.raises(RuntimeError, match='Event loop is closed'):
await loop.run_aio_coroutine(coro)
with test_utils.deprecate(self):
with pytest.raises(RuntimeError, match='Event loop is closed'):
await loop.run_coroutine(coro)
with pytest.raises(RuntimeError, match='Event loop is closed'):
loop.add_signal_handler(signal.SIGTERM, func)
finally:
Expand Down
38 changes: 3 additions & 35 deletions tests/aiotest/test_coroutine.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from tests import aiotest
import trio_asyncio
import pytest
from .. import utils as test_utils


async def hello_world(asyncio, result, delay, loop):
result.append("Hello")
# retrieve the event loop from the policy
await asyncio.sleep(delay, loop=loop)
await asyncio.sleep(delay)
result.append('World')
return "."

Expand All @@ -17,27 +16,13 @@ class TestCoroutine(aiotest.TestCase):
async def test_hello_world(self, loop, config):
result = []
coro = hello_world(config.asyncio, result, 0.001, loop)
await loop.run_aio_coroutine(config.asyncio.ensure_future(coro, loop=loop))
assert result == ['Hello', 'World']

@pytest.mark.trio
async def test_hello_world_depr(self, loop, config):
result = []
coro = hello_world(config.asyncio, result, 0.001, loop)
with test_utils.deprecate(self):
await loop.run_coroutine(config.asyncio.ensure_future(coro, loop=loop))
assert result == ['Hello', 'World']

@pytest.mark.trio
async def run_hello_world(self, loop, config):
result = []
await loop.run_asyncio(hello_world, config.asyncio, result, 0.001, loop)
await loop.run_aio_coroutine(config.asyncio.ensure_future(coro))
assert result == ['Hello', 'World']

@pytest.mark.trio
async def test_waiter(self, loop, config):
async def waiter(asyncio, hello_world, result):
fut = asyncio.Future(loop=loop)
fut = asyncio.Future()
loop.call_soon(fut.set_result, "Future")

value = await fut
Expand All @@ -49,20 +34,3 @@ async def waiter(asyncio, hello_world, result):
result = []
await trio_asyncio.aio_as_trio(waiter)(config.asyncio, hello_world, result)
assert result == ['Future', 'Hello', 'World', '.']

@pytest.mark.trio
async def test_waiter_depr(self, loop, config):
async def waiter(asyncio, hello_world, result):
fut = asyncio.Future(loop=loop)
loop.call_soon(fut.set_result, "Future")

value = await fut
result.append(value)

value = await hello_world(asyncio, result, 0.001, loop)
result.append(value)

result = []
with test_utils.deprecate(self):
await loop.run_asyncio(waiter, config.asyncio, hello_world, result)
assert result == ['Future', 'Hello', 'World', '.']
2 changes: 1 addition & 1 deletion tests/aiotest/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def test_tcp_hello(self, loop, config):

proto = TcpEchoClientProtocol(message, loop)
coro = loop.create_connection(lambda: proto, host, port)
await loop.run_coroutine(coro)
await loop.run_aio_coroutine(coro)
assert proto.state != 'new'

await loop.stop().wait()()
Expand Down
58 changes: 0 additions & 58 deletions tests/aiotest/test_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import pytest
import trio
import trio_asyncio
from .. import utils as test_utils


class TestThread(aiotest.TestCase):
Expand All @@ -27,28 +26,6 @@ def work():
assert work_ident is not None
assert work_ident != get_ident()

@pytest.mark.trio
async def test_ident_depr(self, loop, config):
threading = config.threading
try:
get_ident = threading.get_ident # Python 3
except AttributeError:
get_ident = threading._get_ident # Python 2

result = {'ident': None}

def work():
result['ident'] = get_ident()

fut = loop.run_in_executor(None, work)
with test_utils.deprecate(self):
await loop.run_coroutine(fut)

# ensure that work() was executed in a different thread
work_ident = result['ident']
assert work_ident is not None
assert work_ident != get_ident()

@pytest.mark.trio
async def test_run_twice(self, loop):
result = []
Expand All @@ -65,24 +42,6 @@ def work():
await loop.run_aio_future(fut)
assert result == ["run", "run"]

@pytest.mark.trio
async def test_run_twice_depr(self, loop):
result = []

def work():
result.append("run")

fut = loop.run_in_executor(None, work)
with test_utils.deprecate(self):
await loop.run_future(fut)
assert result == ["run"]

# ensure that run_in_executor() can be called twice
fut = loop.run_in_executor(None, work)
with test_utils.deprecate(self):
await loop.run_future(fut)
assert result == ["run", "run"]

@pytest.mark.trio
async def test_policy(self, loop, config):
asyncio = config.asyncio
Expand All @@ -99,23 +58,6 @@ def work():
await loop.run_aio_future(fut)
assert isinstance(result['loop'], (AssertionError, RuntimeError))

@pytest.mark.trio
async def test_policy_depr(self, loop, config):
asyncio = config.asyncio
result = {'loop': 'not set'} # sentinel, different than None

def work():
try:
result['loop'] = asyncio.get_event_loop()
except Exception as exc:
result['loop'] = exc

# get_event_loop() must return None in a different thread
fut = loop.run_in_executor(None, work)
with test_utils.deprecate(self):
await loop.run_future(fut)
assert isinstance(result['loop'], (AssertionError, RuntimeError))

@pytest.mark.trio
async def test_run_in_thread(self, config):
threading = config.threading
Expand Down
Loading