A runner that does not really allow async execution, and just advance the coroutine. See discussion in https://github.com/python-trio/trio/issues/608, Credit to Nathaniel Smith
(coro)
| 56 | |
| 57 | |
| 58 | def _pseudo_sync_runner(coro): |
| 59 | """ |
| 60 | A runner that does not really allow async execution, and just advance the coroutine. |
| 61 | |
| 62 | See discussion in https://github.com/python-trio/trio/issues/608, |
| 63 | |
| 64 | Credit to Nathaniel Smith |
| 65 | |
| 66 | """ |
| 67 | try: |
| 68 | coro.send(None) |
| 69 | except StopIteration as exc: |
| 70 | return exc.value |
| 71 | else: |
| 72 | # TODO: do not raise but return an execution result with the right info. |
| 73 | raise RuntimeError( |
| 74 | "{coro_name!r} needs a real async loop".format(coro_name=coro.__name__) |
| 75 | ) |
| 76 | |
| 77 | |
| 78 | def _asyncify(code: str) -> str: |