art049 / art049/my-python-event-loop

Code Restructure

Đang mở
#3 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
15
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Enjoyed reading your code. It was quite comprehensive for your EuroPython 2024 talk. However, there were a few ideas that might make it more concise. This is a worthwhile project that you should pick back up. These are a few, but not all, of my quick observations. Implementing these may allow plugins for SELinux and osquery. Since coreutils is your home, these modifications could enable PyO3 stub files for an overlay over coreutils.

1. Binary search of cron schedules isnt very scalable.
- I'd use a heap or BST for these times. That way you can have horizontally distributed cron reads
- If you were to use your FastAPI lambda endpoint as a front-end for a SIEM, which isnt a bad idea, you would want to load balance this
- Might even be worth decoupling the call_at fxn

2. Passable locks associated with your handle data structure: parking-lot based queues
- Sometimes theres multiple handlers: for instance, high end TDM systems
- If you were to pass the per-thread loop context to PyO3/Rust, you may need to consider handling CFFI concurrency interrupts

3. Due to 2, _run_once should be rewritten to preempt... OnceLock and RwLocks would be seen here
- If you have a high end TDM system, you could have different loop contexts lock expensive resources and/or operations

4. Some of your code is redundant... abstract yourself of simple getters/setters
- Create a metaclass to help your trivial methods

5. Make the selector a TypedDict (inline dictionary in 3.14) or a dataclass
- _add_reader() and _add_writer() have been made inflexible
- Cut the implementation specific dependency so that events can be plugins
- This permits contextual EVENT_WRITEs...

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

Hướng nghiên cứu

Issue nêu các điểm vào của event loop là call_at, _run_once, _add_reader(), _add_writer(), selector và dữ liệu handle. Hãy bắt đầu bằng cách lập bản đồ các điểm vào đó và các mối quan hệ hiện tại của chúng; không có tệp hoặc test nào được nêu tên. Công việc được yêu cầu không bị giới hạn ở một thay đổi duy nhất, và issue không định nghĩa tiêu chí hoàn thành rõ rà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ệ
fastapi, python, rust
Lĩnh vực
backend, operating-systems
Loại issue
Tái cấu trúc
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
15/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.