Skip to content

Commit 024058d

Browse files
committed
* trio.hazmat.Result is deprecated.
1 parent 5772281 commit 024058d

5 files changed

Lines changed: 22 additions & 12 deletions

File tree

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
trio-asyncio (0.7.5-1) unstable; urgency=medium
2+
3+
* trio.hazmat.Result is deprecated.
4+
5+
-- Matthias Urlichs <matthias@urlichs.de> Mon, 23 Jul 2018 20:54:55 +0200
6+
17
trio-asyncio (0.7.4-5) unstable; urgency=medium
28

39
* Debianization

trio_asyncio/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file is imported from __init__.py and exec'd from setup.py
22

3-
__version__ = "0.7.4"
3+
__version__ = "0.7.5"

trio_asyncio/child.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import threading
44
import weakref
5+
import outcome
56

67
import trio
78

@@ -37,7 +38,8 @@ def _compute_returncode(status):
3738
raise UnknownStatus(status)
3839

3940

40-
NOT_FOUND = trio.hazmat.Error(ChildProcessError())
41+
def NOT_FOUND():
42+
return outcome.Error(ChildProcessError())
4143

4244

4345
class ProcessWaiter:
@@ -131,7 +133,7 @@ def _wait_pid(self, blocking):
131133
except ChildProcessError:
132134
# The child process may already be reaped
133135
# (may happen if waitpid() is called elsewhere).
134-
self.__result = NOT_FOUND
136+
self.__result = NOT_FOUND()
135137
else:
136138
if pid == 0:
137139
# The child process is still alive.
@@ -141,7 +143,7 @@ def _wait_pid(self, blocking):
141143

142144
def _handle_exitstatus(self, sts):
143145
"""This overrides an internal API of subprocess.Popen"""
144-
self.__result = trio.hazmat.Result.capture(_compute_returncode, sts)
146+
self.__result = outcome.capture(_compute_returncode, sts)
145147

146148
@property
147149
def returncode(self):

trio_asyncio/sync.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import queue
33
import asyncio
44
import threading
5+
import outcome
56

67
from .base import BaseTrioEventLoop
78
from .handles import Handle
@@ -135,7 +136,7 @@ async def _run_coroutine(self, future):
135136
def is_done(_):
136137
nonlocal result
137138

138-
result = trio.hazmat.Result.capture(future.result)
139+
result = outcome.capture(future.result)
139140
self.stop()
140141

141142
future.add_done_callback(is_done)
@@ -198,11 +199,11 @@ async def __trio_thread_main(self):
198199
break
199200
async_fn, args = req
200201

201-
result = await trio.hazmat.Result.acapture(async_fn, *args)
202-
if type(result) == trio.hazmat.Error and type(result.error) == trio.Cancelled:
202+
result = await outcome.acapture(async_fn, *args)
203+
if type(result) == outcome.Error and type(result.error) == trio.Cancelled:
203204
res = RuntimeError("Main loop cancelled")
204205
res.__cause__ = result.error.__cause__
205-
result = trio.hazmat.Error(res)
206+
result = outcome.Error(res)
206207
self.__blocking_result_queue.put(result)
207208
with trio.open_cancel_scope(shield=True):
208209
await self._main_loop_exit()

trio_asyncio/util.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import trio
55
import asyncio
66
import sys
7+
import outcome
78
from async_generator import async_generator, yield_
89

910
__all__ = ['run_future']
@@ -20,7 +21,7 @@ async def run_future(future):
2021
raise_cancel = None
2122

2223
def done_cb(_):
23-
trio.hazmat.reschedule(task, trio.hazmat.Result.capture(future.result))
24+
trio.hazmat.reschedule(task, outcome.capture(future.result))
2425

2526
future.add_done_callback(done_cb)
2627

@@ -60,14 +61,14 @@ async def run_generator(loop, async_generator):
6061
async def consume_next():
6162
try:
6263
item = await async_generator.__anext__()
63-
result = trio.hazmat.Value(value=item)
64+
result = outcome.Value(value=item)
6465
except StopAsyncIteration:
65-
result = trio.hazmat.Value(value=STOP)
66+
result = outcome.Value(value=STOP)
6667
except asyncio.CancelledError:
6768
# Once we are cancelled, we do not call reschedule() anymore
6869
return
6970
except Exception as e:
70-
result = trio.hazmat.Error(error=e)
71+
result = outcome.Error(error=e)
7172

7273
trio.hazmat.reschedule(task, result)
7374

0 commit comments

Comments
 (0)