1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
---input---
>>> from multiprocessing import Pool
>>> p = Pool(5)
>>> def f(x):
... return x*x
...
>>> with p:
... p.map(f, [1,2,3])
Process PoolWorker-1:
Process PoolWorker-2:
Process PoolWorker-3:
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
---tokens---
'>>> ' Generic.Prompt
'from' Keyword.Namespace
' ' Text
'multiprocessing' Name.Namespace
' ' Text
'import' Keyword.Namespace
' ' Text
'Pool' Name
'\n' Text.Whitespace
'>>> ' Generic.Prompt
'p' Name
' ' Text
'=' Operator
' ' Text
'Pool' Name
'(' Punctuation
'5' Literal.Number.Integer
')' Punctuation
'\n' Text.Whitespace
'>>> ' Generic.Prompt
'def' Keyword
' ' Text
'f' Name.Function
'(' Punctuation
'x' Name
')' Punctuation
':' Punctuation
'\n' Text.Whitespace
'... ' Generic.Prompt
' ' Text
'return' Keyword
' ' Text
'x' Name
'*' Operator
'x' Name
'\n' Text.Whitespace
'...' Generic.Prompt
'\n' Text.Whitespace
'>>> ' Generic.Prompt
'with' Keyword
' ' Text
'p' Name
':' Punctuation
'\n' Text.Whitespace
'... ' Generic.Prompt
' ' Text
'p' Name
'.' Operator
'map' Name
'(' Punctuation
'f' Name
',' Punctuation
' ' Text
'[' Punctuation
'1' Literal.Number.Integer
',' Punctuation
'2' Literal.Number.Integer
',' Punctuation
'3' Literal.Number.Integer
']' Punctuation
')' Punctuation
'\n' Text.Whitespace
'Process PoolWorker-1:\n' Generic.Output
'Process PoolWorker-2:\n' Generic.Output
'Process PoolWorker-3:\n' Generic.Output
'Traceback (most recent call last):\n' Generic.Traceback
'Traceback (most recent call last):\n' Generic.Traceback
'Traceback (most recent call last):\n' Generic.Traceback
'AttributeError' Generic.Error
': ' Text
"Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>" Name
'\n' Text.Whitespace
"AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>\n" Other
"AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>\n" Other
|