Cannot get actors to work with async / await
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- distributed-systems, documentation
Hướng nghiên cứu
Bắt đầu với các ví dụ actor async/await trong tài liệu actor được liên kết và chạy bản tái hiện Python đầy đủ với một Client cục bộ. So sánh hành vi được ghi lại trong tài liệu với traceback, sau đó xác minh rằng ví dụ actor bất đồng bộ hoạt động và ví dụ Waiter sử dụng khai báo chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I have been searching for an actor framework in Python with good asyncio integration and appear to have found it!! However, running the examples from the docs on using actors with async/await yields an error. The complete code I am trying to run (copied from the examples) follows:
import asyncio
from dask.distributed import Client
class Counter:
""" A simple class to manage an incrementing counter """
n = 0
def __init__(self):
self.n = 0
def increment(self):
self.n += 1
return self.n
def add(self, x):
self.n += x
return self.n
async def test_async(client: Client) -> None:
counter = await client.submit(Counter, actor=True)
await counter.increment()
n = await counter.n
print(f'n = {n}')
if __name__ == '__main__':
client = Client()
asyncio.run(test_async(client))
Here is the full text of the error:
Traceback (most recent call last):
File "D:\Users\charl\Documents\2_dask\dask_test.py", line 30, in <module>
asyncio.run(test_async(client))
File "C:\Users\charl\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\charl\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\charl\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 684, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "D:\Users\charl\Documents\2_dask\dask_test.py", line 21, in test_async
counter = await client.submit(Counter, actor=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Users\charl\Documents\2_dask\.venv\Lib\site-packages\distributed\client.py", line 620, in __await__
return self.result().__await__()
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Users\charl\Documents\2_dask\.venv\Lib\site-packages\distributed\actor.py", line 165, in __getattr__
attr = getattr(self._cls, key)
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Counter' has no attribute '__await__'. Did you mean: '__init__'?
2024-11-16 13:03:27,968 - distributed.scheduler - WARNING - Removing worker 'tcp://127.0.0.1:62438' caused the cluster to lose already computed task(s), which will be recomputed elsewhere: {'Counter-23599479-2f43-4126-92ac-58b1f172a47e'} (stimulus_id='handle-worker-cleanup-1731783807.9682791')
Also as a side note, this text from the example using async in an actor function appears to have a typo (should be class Waiter not def Waiter)
- Ngôn ngữ chính
- Python
- Star
- 1.7k
- Fork
- 778
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
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.
Issue khác của dask/distributed
-
needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
dask/distributed#9366 ·
-
needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
dask/distributed#9353 ·
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
dask/distributed#8304 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
dask/distributed#4816 · 2 bình luận ·
-
documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
dask/distributed#2378 · 2 bình luận ·
Tất cả issue của dask/distributed
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
qgis/QGIS-Plugins-Website#459 ·
-
bug severity:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
bot-found bug priority: P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
madenvel/KalinkaPlayer#179 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ls1intum/edutelligence#1098 ·
Maintainer thường phản hồi trong vòng 1 ngày