MagicStack / MagicStack/uvloop
set_exception_handler is not handling exception as expected.
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Cython
- Estrellas
- 11.9k
- Forks
- 616
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
- uvloop version: 0.14.0
- Python version: 3.6.9
- Platform: Linux c965e3d4adf2 5.3.0-1032-gcp #34~18.04.1-Ubuntu SMP
- Can you reproduce the bug with
PYTHONASYNCIODEBUGin env?: yes - Does uvloop behave differently from vanilla asyncio? How?:
Yes asyncio default loop catches TimeoutError: [Errno 110] Connection timed out whereas uvloop closes the loop and throws RuntimeError: Event loop stopped before Future completed.
I ran across this bug when dealing with websockets (you could see the issue - https://github.com/aaugustin/websockets/issues/823)
To log this error :
def handle_async_exception(loop, ctx):
logger.error("Loop error occured", ctx=ctx)
loop = asyncio.get_event_loop()
loop.set_exception_handler(handle_async_exception)
Python websockets throw a TimeoutError when a client is not found in a certain time limit (for ping/ pongs). In asyncio, the error is bubbled to set_exception_handler, and I could log it there as expected. However in uvloop, instead of having the exception being bubbled to exception_handler, it shuts down the loop. I get the following error:
Process Process-9:
Traceback (most recent call last):
File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "/home/streaming/app/emitter_app/emitter.py", line 60, in start_emitter
loop.run_until_complete(asyncio.gather(server.serve(), push_payload(queue)))
File "uvloop/loop.pyx", line 1454, in uvloop.loop.Loop.run_until_complete
RuntimeError: Event loop stopped before Future completed.
Thanks for your time! Appreciate such a neat package to make asyncio faster in python.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza comparando uvloop/loop.pyx alrededor de run_until_complete (línea 1454) con el manejo de set_exception_handler de vanilla asyncio. Reproduce el escenario de timeout de websockets con Python 3.6.9 y PYTHONASYNCIODEBUG activado; se considera terminado cuando el TimeoutError llega al gestor de excepciones configurado sin detener inesperadamente el bucle.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend, networking
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100