用法:
class distributed.LocalCluster(name=None, n_workers=None, threads_per_worker=None, processes=None, loop=None, start=None, host=None, ip=None, scheduler_port=0, silence_logs=30, dashboard_address=':8787', worker_dashboard_address=None, diagnostics_port=None, services=None, worker_services=None, service_kwargs=None, asynchronous=False, security=None, protocol=None, blocked_handlers=None, interface=None, worker_class=None, scheduler_kwargs=None, scheduler_sync_interval=1, **worker_kwargs)
創建本地調度程序和工作人員
這將創建一個 “cluster” 的調度程序和在本地機器上運行的工作人員。
- n_workers: int:
開始工作的工人數量
- processes: bool:
是使用進程 (True) 還是線程 (False)。默認為 True,除非worker_class=Worker,在這種情況下默認為 False。
- threads_per_worker: int:
每個工人的線程數
- scheduler_port: int:
調度程序的端口。默認8786,使用0選擇隨機端口
- silence_logs: logging level:
要打印到標準輸出的日誌級別。
logging.WARN
默認情況下。使用 False 或 None 之類的虛假值來保持不變。- host: string:
調度程序將偵聽的主機地址,默認僅為 localhost
- ip: string:
已棄用。參見上麵的
host
。- dashboard_address: str:
偵聽 Bokeh 診斷服務器的地址,例如“localhost:8787”或“0.0.0.0:8787”。默認為“:8787”。設置為
None
以禁用儀表板。使用“:0”作為隨機端口。- worker_dashboard_address: str:
監聽 Bokeh 工作診斷服務器的地址,例如“localhost:8787”或“0.0.0.0:8787”。默認為 None 禁用儀表板。使用“:0”作為隨機端口。
- diagnostics_port: int:
已棄用。見dashboard_address。
- asynchronous: bool (False by default):
如果在 async/await 函數或 Tornado gen.coroutines 中使用此集群,則設置為 True。對於正常使用,這應該保持為 False。
- blocked_handlers: List[str]:
字符串列表,指定在調度程序上禁止的處理程序的阻止列表,例如
['feed', 'run_function']
- service_kwargs: Dict[str, Dict]:
額外的關鍵字交給正在運行的服務
- security:安全或布爾,可選
配置此集群中的通信安全性。可以是安全對象,也可以是 True。如果為 True,將自動創建臨時 self-signed 憑據。
- protocol: str (optional):
使用的協議,如
tcp://
,tls://
,inproc://
給定其他關鍵字參數,如processes
和security
,這默認為明智的選擇- interface: str (optional):
要使用的網絡接口。默認為 lo/localhost
- worker_class: Worker:
工人類用於實例化工人。如果 processes=False 則默認為 Worker,如果 processes=True 或省略則默認為 Nanny。
- **worker_kwargs:
額外的工人參數。任何其他關鍵字參數都將傳遞給
Worker
類構造函數。
參數:
例子:
>>> cluster = LocalCluster() # Create a local cluster >>> cluster LocalCluster("127.0.0.1:8786", workers=8, threads=8)
>>> c = Client(cluster) # connect to local cluster
將集群擴展到三個工作人員
>>> cluster.scale(3)
將額外的關鍵字參數傳遞給 Bokeh
>>> LocalCluster(service_kwargs={'dashboard': {'prefix': '/foo'}})
相關用法
- Python distributed.Lock用法及代碼示例
- Python distributed.Lock.acquire用法及代碼示例
- Python distributed.protocol.serialize.register_generic用法及代碼示例
- Python distributed.Client.gather用法及代碼示例
- Python distributed.recreate_tasks.ReplayTaskClient.recreate_task_locally用法及代碼示例
- Python distributed.diagnostics.plugin.SchedulerPlugin用法及代碼示例
- Python distributed.Client.ncores用法及代碼示例
- Python distributed.Client.retire_workers用法及代碼示例
- Python distributed.Client.unregister_worker_plugin用法及代碼示例
- Python distributed.fire_and_forget用法及代碼示例
- Python distributed.Client.set_metadata用法及代碼示例
- Python distributed.Client.scheduler_info用法及代碼示例
- Python distributed.Client.submit用法及代碼示例
- Python distributed.Client.compute用法及代碼示例
- Python distributed.SpecCluster.scale用法及代碼示例
- Python distributed.get_worker用法及代碼示例
- Python distributed.SpecCluster.scale_up用法及代碼示例
- Python distributed.Client.nthreads用法及代碼示例
- Python distributed.comm.resolve_address用法及代碼示例
- Python distributed.Client.unpublish_dataset用法及代碼示例
注:本文由純淨天空篩選整理自dask.org大神的英文原創作品 distributed.LocalCluster。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。