Commit dd2fe54
Clean future cancellation handling (#1687)
Summary:
Pull Request resolved: #1687
The implementation of `monarch.actor.Future` uses `loop.call_soon_threadsafe` to set a value/exception on an underlying asyncio future. But if the caller cancelled the asyncio future before `call_soon_threadsafe` executes the callback, then `asyncio.exceptions.InvalidStateError` will be logged, which is noisy and misleading.
This diff solves the issue by checking whether the future is already resolved/cancelled from inside the callback.
ghstack-source-id: 319407775
exported-using-ghexport
Reviewed By: zdevito
Differential Revision: D85693875
fbshipit-source-id: eb515cd65e78fcbb853909af3ba96196c1315c981 parent 5afdea6 commit dd2fe54
1 file changed
+11
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
141 | 149 | | |
142 | 150 | | |
143 | | - | |
| 151 | + | |
144 | 152 | | |
145 | | - | |
146 | | - | |
| 153 | + | |
| 154 | + | |
147 | 155 | | |
148 | 156 | | |
149 | 157 | | |
| |||
0 commit comments