가끔 인수없이 함수에 다중 처리를 사용해야합니다. 나는 같은 것을 할 수 있으면 좋겠다 : 나는 Process(target=f, args=())
할 수map/imap/imap_unordered를 인자없이 함수와 함께 사용할 수 있습니까?
from multiprocessing import Pool
def f(): # no argument
return 1
# TypeError: f() takes no arguments (1 given)
print Pool(2).map(f, range(10))
을,하지만 난 map
/imap
/imap_unordered
의 구문을 선호합니다. 그렇게 할 수있는 방법이 있습니까?
하나의 인수를 무시하고 무시하기 위해'f'를 재정의 하시겠습니까? – inspectorG4dget
@ inspectorG4dget : 아니요, 차라리 피하려고합니다. –
이것이 [XY 문제]라고 생각합니다. (http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). 이제 한 걸음 뒤로 물러나보십시오. 실제로이 기능을 사용하려고 시도하고있는 것은 무엇입니까? – inspectorG4dget