reactive-python / reactpy

It's React, but in Python
https://reactpy.dev
MIT License
7.89k stars 317 forks source link

`anyio>=4.0` breaks our backend implementations #1167

Open Archmonger opened 11 months ago

Archmonger commented 11 months ago

Current Situation

Looks like some changes to the latest versions of anyio fundamentally breaks how we currently spawn our backends.

Exception in thread Thread-3 (run_dispatcher):
Traceback (most recent call last):
  File "C:\Users\Markg\Documents\Repositories\_testbed\.venv\lib\site-packages\reactpy\backend\flask.py", line 225, in main
    await serve_layout(
  File "C:\Users\Markg\Documents\Repositories\_testbed\.venv\lib\site-packages\reactpy\core\serve.py", line 42, in serve_layout
    async with create_task_group() as task_group:
  File "C:\Users\Markg\Documents\Repositories\_testbed\.venv\lib\site-packages\anyio\_backends\_asyncio.py", line 668, in __aexit__
    raise cancelled_exc_while_waiting_tasks
  File "C:\Users\Markg\Documents\Repositories\_testbed\.venv\lib\site-packages\anyio\_backends\_asyncio.py", line 648, in __aexit__
    await asyncio.wait(self.cancel_scope._tasks)
  File "C:\Users\Markg\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 384, in wait
    return await _wait(fs, timeout, return_when, loop)
  File "C:\Users\Markg\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 491, in _wait
    await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Markg\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\Markg\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Markg\Documents\Repositories\_testbed\.venv\lib\site-packages\flask\ctx.py", line 181, in wrapper
    return reqctx.app.ensure_sync(f)(*args, **kwargs)
  File "C:\Users\Markg\Documents\Repositories\_testbed\.venv\lib\site-packages\reactpy\backend\flask.py", line 253, in run_dispatcher
    loop.run_until_complete(main_future)
  File "C:\Users\Markg\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
asyncio.exceptions.CancelledError

Proposed Actions

Create compatibility for anyio>=4.0, or limit anyio to <4.0.