매개 변수,하지만이 코드 조각은executor.map 및 비 terating 내가 파이썬 3.2 <code>concurrent.futures</code>에 많은 쿨러 멀티 (에 스레드를 사용하는 내 스크립트를 변환하려고
with ThreadPoolExecutor(max_workers=MAX_THREADS) as executor:
for result in executor.map(lambda h:
validate_hostname(h, pci_ids, options.verbose),
get_all_hostnames()):
내가 오류 _pickle.PicklingError: Can't pickle <class 'function'>: attribute lookup builtins.function failed
을 얻을 충돌합니다. this answer을 읽을 때 executor.map()
의 매개 변수로 람다 함수를 사용할 수 없다고 생각하고 executor.map()
을 작성하려면 하나의 매개 변수 함수를 개발해야하지만 그 중 pci_ids
과 options.verbose
은 변수이므로 지정할 수 없습니다. 도움말 기능에서 고정 된 값으로 표시합니다.
어떤 아이디어가 필요합니까?
아, 감사합니다. – mcepl
THX 나를 위해 일했습니다! 그러나 생성자 표현식이 충분할 때 목록을 인스턴스화하지 않아야하므로'executor.map (get_all_hostnames()에서 호스트에 대해 (호스트, pci_ids, options.verbose) – georg