Skip to content

Commit

Permalink
open_cancel_scope → CancelScope
Browse files Browse the repository at this point in the history
Closes: #52
  • Loading branch information
smurfix committed Feb 12, 2019
1 parent fef81f9 commit 4990c61
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Maintainer: Matthias Urlichs <[email protected]>
Section: python
Priority: optional
Build-Depends: dh-python, python3-setuptools, python3-all, debhelper (>= 9),
python3-trio (>= 0.5.0),
python3-trio (>= 0.10.0),
python3-pytest-trio,
python3-pytest-runner,
python3-outcome,
Expand All @@ -13,7 +13,7 @@ Homepage: https://github.com/smurfix/trio-asyncio
Package: python3-trio-asyncio
Architecture: all
Depends: ${misc:Depends}, ${python3:Depends},
python3-trio (>= 0.5.0),
python3-trio (>= 0.10.0),
python3-outcome,
Description: Re-implementation of the asyncio mainloop on top of Trio
trio_asyncio allows you to call asyncio code from within Trio,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"""

install_requires = [
"trio >= 0.9.0",
"trio >= 0.10.0",
"async_generator >= 1.6",
"outcome",
]
Expand Down
4 changes: 2 additions & 2 deletions tests/interop/test_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def cancelled_future(seen):
return f # contains error

async def check_cancel(proc, seen):
with trio.open_cancel_scope() as scope:
with trio.CancelScope() as scope:
with pytest.raises(asyncio.CancelledError):
await self.call_t_a(proc, seen, loop=loop)
assert not scope.cancel_called
Expand Down Expand Up @@ -359,7 +359,7 @@ def cancelled_future(seen):
return f # contains error

async def check_cancel(proc, seen):
with trio.open_cancel_scope() as scope:
with trio.CancelScope() as scope:
with pytest.raises(asyncio.CancelledError):
await self.call_t_a_depr(proc, seen, loop=loop)
assert not scope.cancel_called
Expand Down
4 changes: 2 additions & 2 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ async def work_in_trio_no_matter_what(*, task_status=trio.TASK_STATUS_IGNORED):
await trio_asyncio.aio_as_trio(work_in_asyncio)()
try:
# KeyboardInterrupt won't cancel this coroutine thanks to the shield
with trio.open_cancel_scope(shield=True):
with trio.CancelScope(shield=True):
task_status.started()
await asyncio_loop_closed.wait()
finally:
Expand All @@ -323,7 +323,7 @@ async def work_in_asyncio():
await asyncio.sleep(0)

async def run_asyncio_loop(nursery, *, task_status=trio.TASK_STATUS_IGNORED):
with trio.open_cancel_scope() as cancel_scope:
with trio.CancelScope() as cancel_scope:
try:
async with trio_asyncio.open_loop():
# Starting a coroutine from here make it inherit the access
Expand Down
6 changes: 3 additions & 3 deletions trio_asyncio/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ async def __run_trio(self, h):
if f.cancelled(): # pragma: no cover
return
try:
with trio.open_cancel_scope() as scope:
with trio.CancelScope() as scope:
h._scope = scope
res = await proc(*args)
if scope.cancelled_caught:
Expand Down Expand Up @@ -582,7 +582,7 @@ def _set_read_handle(self, fd, handle):

async def _reader_loop(self, fd, handle, task_status=trio.TASK_STATUS_IGNORED):
task_status.started()
with trio.open_cancel_scope() as scope:
with trio.CancelScope() as scope:
handle._scope = scope
try:
while not handle._cancelled: # pragma: no branch
Expand Down Expand Up @@ -635,7 +635,7 @@ def _set_write_handle(self, fd, handle):
return writer

async def _writer_loop(self, fd, handle, task_status=trio.TASK_STATUS_IGNORED):
with trio.open_cancel_scope() as scope:
with trio.CancelScope() as scope:
handle._scope = scope
task_status.started()
try:
Expand Down
4 changes: 2 additions & 2 deletions trio_asyncio/handles.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async def _call_async(self, task_status=trio.TASK_STATUS_IGNORED):
return
task_status.started()
try:
with trio.open_cancel_scope() as scope:
with trio.CancelScope() as scope:
self._scope = scope
if self._is_sync is None:
await self._context.run(_set_sniff, self._callback, self)
Expand All @@ -129,7 +129,7 @@ async def _call_async(self, task_status=trio.TASK_STATUS_IGNORED):
return
task_status.started()
try:
with trio.open_cancel_scope() as scope:
with trio.CancelScope() as scope:
self._scope = scope
if self._is_sync is None:
await self._callback(self)
Expand Down
2 changes: 1 addition & 1 deletion trio_asyncio/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ async def __trio_thread_main(self):
res.__cause__ = result.error.__cause__
result = outcome.Error(res)
self.__blocking_result_queue.put(result)
with trio.open_cancel_scope(shield=True):
with trio.CancelScope(shield=True):
await self._main_loop_exit()
self.__blocking_result_queue.put(None)
nursery.cancel_scope.cancel()
Expand Down

0 comments on commit 4990c61

Please sign in to comment.