MagicStack / MagicStack/uvloop
set_exception_handler is not handling exception as expected.
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Cython
- Star
- 11.9k
- Fork
- 616
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
- 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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách so sánh uvloop/loop.pyx xung quanh run_until_complete (dòng 1454) với cách vanilla asyncio xử lý set_exception_handler. Tái hiện kịch bản timeout của websockets trên Python 3.6.9 với PYTHONASYNCIODEBUG được bật; được xem là hoàn tất khi TimeoutError đến được trình xử lý ngoại lệ đã cấu hình mà không làm dừng loop một cách bất ngờ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- backend, networking
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100