@@ -37,25 +37,26 @@ async def dispatch_single_view(
37
37
task_group .start_soon (_single_incoming_loop , layout , recv )
38
38
39
39
40
- _SharedDispatchFuture = Callable [[SendCoroutine , RecvCoroutine ], Future ]
40
+ _SharedViewDispatcherFuture = Callable [[SendCoroutine , RecvCoroutine ], Future [None ]]
41
+ _SharedViewDispatcherCoro = Callable [[SendCoroutine , RecvCoroutine ], Awaitable [None ]]
41
42
42
43
43
44
@asynccontextmanager
44
45
async def create_shared_view_dispatcher (
45
46
layout : Layout , run_forever : bool = False
46
- ) -> AsyncIterator [_SharedDispatchFuture ]:
47
+ ) -> AsyncIterator [_SharedViewDispatcherFuture ]:
47
48
with layout :
48
49
(
49
50
dispatch_shared_view ,
50
51
model_state ,
51
52
all_update_queues ,
52
53
) = await _make_shared_view_dispatcher (layout )
53
54
54
- dispatch_tasks : List [Future ] = []
55
+ dispatch_tasks : List [Future [ None ] ] = []
55
56
56
57
def dispatch_shared_view_soon (
57
58
send : SendCoroutine , recv : RecvCoroutine
58
- ) -> Future :
59
+ ) -> Future [ None ] :
59
60
future = ensure_future (dispatch_shared_view (send , recv ))
60
61
dispatch_tasks .append (future )
61
62
return future
@@ -87,10 +88,10 @@ def dispatch_shared_view_soon(
87
88
88
89
def ensure_shared_view_dispatcher_future (
89
90
layout : Layout ,
90
- ) -> Tuple [Future , _SharedDispatchFuture ]:
91
- dispatcher_future = Future ()
91
+ ) -> Tuple [Future [ None ], _SharedViewDispatcherCoro ]:
92
+ dispatcher_future : Future [ _SharedViewDispatcherCoro ] = Future ()
92
93
93
- async def dispatch_shared_view_forever ():
94
+ async def dispatch_shared_view_forever () -> None :
94
95
with layout :
95
96
(
96
97
dispatch_shared_view ,
@@ -113,12 +114,9 @@ async def dispatch(send: SendCoroutine, recv: RecvCoroutine) -> None:
113
114
return ensure_future (dispatch_shared_view_forever ()), dispatch
114
115
115
116
116
- _SharedDispatchCoroutine = Callable [[SendCoroutine , RecvCoroutine ], Awaitable [None ]]
117
-
118
-
119
117
async def _make_shared_view_dispatcher (
120
118
layout : Layout ,
121
- ) -> Tuple [_SharedDispatchCoroutine , Ref [Any ], WeakSet [Queue [LayoutUpdate ]]]:
119
+ ) -> Tuple [_SharedViewDispatcherCoro , Ref [Any ], WeakSet [Queue [LayoutUpdate ]]]:
122
120
initial_update = await layout .render ()
123
121
model_state = Ref (initial_update .apply_to ({}))
124
122
@@ -158,7 +156,7 @@ async def _shared_outgoing_loop(
158
156
159
157
async def _wait_until_first_complete (
160
158
* tasks : Awaitable [Any ],
161
- ) -> Sequence [Future ]:
159
+ ) -> Sequence [Future [ Any ] ]:
162
160
futures = [ensure_future (t ) for t in tasks ]
163
161
await wait (futures , return_when = FIRST_COMPLETED )
164
162
return futures
0 commit comments