@rowstile/cli-linux-x64 0.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (565) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +5 -0
  3. package/package.json +26 -0
  4. package/python/bin/python3.13 +0 -0
  5. package/python/bin/python3.13-config +122 -0
  6. package/python/lib/libpython3.13.so.1.0 +0 -0
  7. package/python/lib/libpython3.so +0 -0
  8. package/python/lib/python3.13/LICENSE.txt +277 -0
  9. package/python/lib/python3.13/__future__.py +147 -0
  10. package/python/lib/python3.13/__hello__.py +16 -0
  11. package/python/lib/python3.13/_aix_support.py +108 -0
  12. package/python/lib/python3.13/_android_support.py +192 -0
  13. package/python/lib/python3.13/_apple_support.py +66 -0
  14. package/python/lib/python3.13/_collections_abc.py +1187 -0
  15. package/python/lib/python3.13/_colorize.py +119 -0
  16. package/python/lib/python3.13/_compat_pickle.py +251 -0
  17. package/python/lib/python3.13/_compression.py +162 -0
  18. package/python/lib/python3.13/_ios_support.py +71 -0
  19. package/python/lib/python3.13/_markupbase.py +396 -0
  20. package/python/lib/python3.13/_opcode_metadata.py +343 -0
  21. package/python/lib/python3.13/_osx_support.py +579 -0
  22. package/python/lib/python3.13/_py_abc.py +147 -0
  23. package/python/lib/python3.13/_pydatetime.py +2640 -0
  24. package/python/lib/python3.13/_pydecimal.py +6356 -0
  25. package/python/lib/python3.13/_pyio.py +2714 -0
  26. package/python/lib/python3.13/_pylong.py +363 -0
  27. package/python/lib/python3.13/_pyrepl/__init__.py +19 -0
  28. package/python/lib/python3.13/_pyrepl/__main__.py +10 -0
  29. package/python/lib/python3.13/_pyrepl/_minimal_curses.py +68 -0
  30. package/python/lib/python3.13/_pyrepl/_threading_handler.py +74 -0
  31. package/python/lib/python3.13/_pyrepl/base_eventqueue.py +110 -0
  32. package/python/lib/python3.13/_pyrepl/commands.py +492 -0
  33. package/python/lib/python3.13/_pyrepl/completing_reader.py +295 -0
  34. package/python/lib/python3.13/_pyrepl/console.py +229 -0
  35. package/python/lib/python3.13/_pyrepl/curses.py +33 -0
  36. package/python/lib/python3.13/_pyrepl/fancy_termios.py +82 -0
  37. package/python/lib/python3.13/_pyrepl/historical_reader.py +419 -0
  38. package/python/lib/python3.13/_pyrepl/input.py +114 -0
  39. package/python/lib/python3.13/_pyrepl/keymap.py +213 -0
  40. package/python/lib/python3.13/_pyrepl/main.py +59 -0
  41. package/python/lib/python3.13/_pyrepl/mypy.ini +29 -0
  42. package/python/lib/python3.13/_pyrepl/pager.py +175 -0
  43. package/python/lib/python3.13/_pyrepl/reader.py +764 -0
  44. package/python/lib/python3.13/_pyrepl/readline.py +599 -0
  45. package/python/lib/python3.13/_pyrepl/simple_interact.py +180 -0
  46. package/python/lib/python3.13/_pyrepl/trace.py +21 -0
  47. package/python/lib/python3.13/_pyrepl/types.py +10 -0
  48. package/python/lib/python3.13/_pyrepl/unix_console.py +852 -0
  49. package/python/lib/python3.13/_pyrepl/unix_eventqueue.py +76 -0
  50. package/python/lib/python3.13/_pyrepl/utils.py +83 -0
  51. package/python/lib/python3.13/_pyrepl/windows_console.py +687 -0
  52. package/python/lib/python3.13/_pyrepl/windows_eventqueue.py +42 -0
  53. package/python/lib/python3.13/_sitebuiltins.py +91 -0
  54. package/python/lib/python3.13/_strptime.py +800 -0
  55. package/python/lib/python3.13/_sysconfigdata__linux_x86_64-linux-gnu.py +1079 -0
  56. package/python/lib/python3.13/_threading_local.py +120 -0
  57. package/python/lib/python3.13/_weakrefset.py +205 -0
  58. package/python/lib/python3.13/abc.py +188 -0
  59. package/python/lib/python3.13/antigravity.py +17 -0
  60. package/python/lib/python3.13/argparse.py +2690 -0
  61. package/python/lib/python3.13/ast.py +1865 -0
  62. package/python/lib/python3.13/asyncio/__init__.py +47 -0
  63. package/python/lib/python3.13/asyncio/__main__.py +211 -0
  64. package/python/lib/python3.13/asyncio/base_events.py +2086 -0
  65. package/python/lib/python3.13/asyncio/base_futures.py +67 -0
  66. package/python/lib/python3.13/asyncio/base_subprocess.py +312 -0
  67. package/python/lib/python3.13/asyncio/base_tasks.py +94 -0
  68. package/python/lib/python3.13/asyncio/constants.py +41 -0
  69. package/python/lib/python3.13/asyncio/coroutines.py +109 -0
  70. package/python/lib/python3.13/asyncio/events.py +885 -0
  71. package/python/lib/python3.13/asyncio/exceptions.py +62 -0
  72. package/python/lib/python3.13/asyncio/format_helpers.py +84 -0
  73. package/python/lib/python3.13/asyncio/futures.py +425 -0
  74. package/python/lib/python3.13/asyncio/locks.py +617 -0
  75. package/python/lib/python3.13/asyncio/log.py +7 -0
  76. package/python/lib/python3.13/asyncio/mixins.py +21 -0
  77. package/python/lib/python3.13/asyncio/proactor_events.py +891 -0
  78. package/python/lib/python3.13/asyncio/protocols.py +216 -0
  79. package/python/lib/python3.13/asyncio/queues.py +309 -0
  80. package/python/lib/python3.13/asyncio/runners.py +217 -0
  81. package/python/lib/python3.13/asyncio/selector_events.py +1328 -0
  82. package/python/lib/python3.13/asyncio/sslproto.py +929 -0
  83. package/python/lib/python3.13/asyncio/staggered.py +174 -0
  84. package/python/lib/python3.13/asyncio/streams.py +787 -0
  85. package/python/lib/python3.13/asyncio/subprocess.py +229 -0
  86. package/python/lib/python3.13/asyncio/taskgroups.py +278 -0
  87. package/python/lib/python3.13/asyncio/tasks.py +1121 -0
  88. package/python/lib/python3.13/asyncio/threads.py +26 -0
  89. package/python/lib/python3.13/asyncio/timeouts.py +185 -0
  90. package/python/lib/python3.13/asyncio/transports.py +337 -0
  91. package/python/lib/python3.13/asyncio/trsock.py +98 -0
  92. package/python/lib/python3.13/asyncio/unix_events.py +1550 -0
  93. package/python/lib/python3.13/asyncio/windows_events.py +906 -0
  94. package/python/lib/python3.13/asyncio/windows_utils.py +181 -0
  95. package/python/lib/python3.13/base64.py +628 -0
  96. package/python/lib/python3.13/bdb.py +973 -0
  97. package/python/lib/python3.13/bisect.py +118 -0
  98. package/python/lib/python3.13/bz2.py +352 -0
  99. package/python/lib/python3.13/cProfile.py +197 -0
  100. package/python/lib/python3.13/calendar.py +813 -0
  101. package/python/lib/python3.13/cmd.py +409 -0
  102. package/python/lib/python3.13/code.py +386 -0
  103. package/python/lib/python3.13/codecs.py +1132 -0
  104. package/python/lib/python3.13/codeop.py +155 -0
  105. package/python/lib/python3.13/collections/__init__.py +1603 -0
  106. package/python/lib/python3.13/colorsys.py +166 -0
  107. package/python/lib/python3.13/compileall.py +470 -0
  108. package/python/lib/python3.13/concurrent/__init__.py +1 -0
  109. package/python/lib/python3.13/concurrent/futures/__init__.py +54 -0
  110. package/python/lib/python3.13/concurrent/futures/_base.py +660 -0
  111. package/python/lib/python3.13/concurrent/futures/process.py +892 -0
  112. package/python/lib/python3.13/concurrent/futures/thread.py +240 -0
  113. package/python/lib/python3.13/configparser.py +1396 -0
  114. package/python/lib/python3.13/contextlib.py +814 -0
  115. package/python/lib/python3.13/contextvars.py +4 -0
  116. package/python/lib/python3.13/copy.py +306 -0
  117. package/python/lib/python3.13/copyreg.py +217 -0
  118. package/python/lib/python3.13/csv.py +527 -0
  119. package/python/lib/python3.13/ctypes/__init__.py +605 -0
  120. package/python/lib/python3.13/ctypes/_aix.py +327 -0
  121. package/python/lib/python3.13/ctypes/_endian.py +78 -0
  122. package/python/lib/python3.13/ctypes/macholib/README.ctypes +7 -0
  123. package/python/lib/python3.13/ctypes/macholib/__init__.py +9 -0
  124. package/python/lib/python3.13/ctypes/macholib/dyld.py +165 -0
  125. package/python/lib/python3.13/ctypes/macholib/dylib.py +42 -0
  126. package/python/lib/python3.13/ctypes/macholib/fetch_macholib +2 -0
  127. package/python/lib/python3.13/ctypes/macholib/fetch_macholib.bat +1 -0
  128. package/python/lib/python3.13/ctypes/macholib/framework.py +42 -0
  129. package/python/lib/python3.13/ctypes/util.py +387 -0
  130. package/python/lib/python3.13/ctypes/wintypes.py +202 -0
  131. package/python/lib/python3.13/curses/__init__.py +101 -0
  132. package/python/lib/python3.13/curses/ascii.py +99 -0
  133. package/python/lib/python3.13/curses/has_key.py +192 -0
  134. package/python/lib/python3.13/curses/panel.py +6 -0
  135. package/python/lib/python3.13/curses/textpad.py +236 -0
  136. package/python/lib/python3.13/dataclasses.py +1679 -0
  137. package/python/lib/python3.13/datetime.py +9 -0
  138. package/python/lib/python3.13/dbm/__init__.py +194 -0
  139. package/python/lib/python3.13/dbm/dumb.py +319 -0
  140. package/python/lib/python3.13/dbm/gnu.py +3 -0
  141. package/python/lib/python3.13/dbm/ndbm.py +3 -0
  142. package/python/lib/python3.13/dbm/sqlite3.py +144 -0
  143. package/python/lib/python3.13/decimal.py +109 -0
  144. package/python/lib/python3.13/difflib.py +2058 -0
  145. package/python/lib/python3.13/dis.py +1075 -0
  146. package/python/lib/python3.13/doctest.py +2919 -0
  147. package/python/lib/python3.13/email/__init__.py +61 -0
  148. package/python/lib/python3.13/email/_encoded_words.py +233 -0
  149. package/python/lib/python3.13/email/_header_value_parser.py +3153 -0
  150. package/python/lib/python3.13/email/_parseaddr.py +563 -0
  151. package/python/lib/python3.13/email/_policybase.py +382 -0
  152. package/python/lib/python3.13/email/architecture.rst +216 -0
  153. package/python/lib/python3.13/email/base64mime.py +115 -0
  154. package/python/lib/python3.13/email/charset.py +396 -0
  155. package/python/lib/python3.13/email/contentmanager.py +254 -0
  156. package/python/lib/python3.13/email/encoders.py +65 -0
  157. package/python/lib/python3.13/email/errors.py +117 -0
  158. package/python/lib/python3.13/email/feedparser.py +536 -0
  159. package/python/lib/python3.13/email/generator.py +530 -0
  160. package/python/lib/python3.13/email/header.py +582 -0
  161. package/python/lib/python3.13/email/headerregistry.py +618 -0
  162. package/python/lib/python3.13/email/iterators.py +68 -0
  163. package/python/lib/python3.13/email/message.py +1217 -0
  164. package/python/lib/python3.13/email/mime/__init__.py +0 -0
  165. package/python/lib/python3.13/email/mime/application.py +37 -0
  166. package/python/lib/python3.13/email/mime/audio.py +97 -0
  167. package/python/lib/python3.13/email/mime/base.py +29 -0
  168. package/python/lib/python3.13/email/mime/image.py +152 -0
  169. package/python/lib/python3.13/email/mime/message.py +33 -0
  170. package/python/lib/python3.13/email/mime/multipart.py +47 -0
  171. package/python/lib/python3.13/email/mime/nonmultipart.py +21 -0
  172. package/python/lib/python3.13/email/mime/text.py +40 -0
  173. package/python/lib/python3.13/email/parser.py +127 -0
  174. package/python/lib/python3.13/email/policy.py +232 -0
  175. package/python/lib/python3.13/email/quoprimime.py +300 -0
  176. package/python/lib/python3.13/email/utils.py +497 -0
  177. package/python/lib/python3.13/encodings/__init__.py +179 -0
  178. package/python/lib/python3.13/encodings/__pycache__/__init__.cpython-313.pyc +0 -0
  179. package/python/lib/python3.13/encodings/__pycache__/aliases.cpython-313.pyc +0 -0
  180. package/python/lib/python3.13/encodings/__pycache__/utf_8.cpython-313.pyc +0 -0
  181. package/python/lib/python3.13/encodings/aliases.py +560 -0
  182. package/python/lib/python3.13/encodings/ascii.py +50 -0
  183. package/python/lib/python3.13/encodings/base64_codec.py +55 -0
  184. package/python/lib/python3.13/encodings/big5.py +39 -0
  185. package/python/lib/python3.13/encodings/big5hkscs.py +39 -0
  186. package/python/lib/python3.13/encodings/bz2_codec.py +78 -0
  187. package/python/lib/python3.13/encodings/charmap.py +69 -0
  188. package/python/lib/python3.13/encodings/cp037.py +307 -0
  189. package/python/lib/python3.13/encodings/cp1006.py +307 -0
  190. package/python/lib/python3.13/encodings/cp1026.py +307 -0
  191. package/python/lib/python3.13/encodings/cp1125.py +698 -0
  192. package/python/lib/python3.13/encodings/cp1140.py +307 -0
  193. package/python/lib/python3.13/encodings/cp1250.py +307 -0
  194. package/python/lib/python3.13/encodings/cp1251.py +307 -0
  195. package/python/lib/python3.13/encodings/cp1252.py +307 -0
  196. package/python/lib/python3.13/encodings/cp1253.py +307 -0
  197. package/python/lib/python3.13/encodings/cp1254.py +307 -0
  198. package/python/lib/python3.13/encodings/cp1255.py +307 -0
  199. package/python/lib/python3.13/encodings/cp1256.py +307 -0
  200. package/python/lib/python3.13/encodings/cp1257.py +307 -0
  201. package/python/lib/python3.13/encodings/cp1258.py +307 -0
  202. package/python/lib/python3.13/encodings/cp273.py +307 -0
  203. package/python/lib/python3.13/encodings/cp424.py +307 -0
  204. package/python/lib/python3.13/encodings/cp437.py +698 -0
  205. package/python/lib/python3.13/encodings/cp500.py +307 -0
  206. package/python/lib/python3.13/encodings/cp720.py +309 -0
  207. package/python/lib/python3.13/encodings/cp737.py +698 -0
  208. package/python/lib/python3.13/encodings/cp775.py +697 -0
  209. package/python/lib/python3.13/encodings/cp850.py +698 -0
  210. package/python/lib/python3.13/encodings/cp852.py +698 -0
  211. package/python/lib/python3.13/encodings/cp855.py +698 -0
  212. package/python/lib/python3.13/encodings/cp856.py +307 -0
  213. package/python/lib/python3.13/encodings/cp857.py +694 -0
  214. package/python/lib/python3.13/encodings/cp858.py +698 -0
  215. package/python/lib/python3.13/encodings/cp860.py +698 -0
  216. package/python/lib/python3.13/encodings/cp861.py +698 -0
  217. package/python/lib/python3.13/encodings/cp862.py +698 -0
  218. package/python/lib/python3.13/encodings/cp863.py +698 -0
  219. package/python/lib/python3.13/encodings/cp864.py +690 -0
  220. package/python/lib/python3.13/encodings/cp865.py +698 -0
  221. package/python/lib/python3.13/encodings/cp866.py +698 -0
  222. package/python/lib/python3.13/encodings/cp869.py +689 -0
  223. package/python/lib/python3.13/encodings/cp874.py +307 -0
  224. package/python/lib/python3.13/encodings/cp875.py +307 -0
  225. package/python/lib/python3.13/encodings/cp932.py +39 -0
  226. package/python/lib/python3.13/encodings/cp949.py +39 -0
  227. package/python/lib/python3.13/encodings/cp950.py +39 -0
  228. package/python/lib/python3.13/encodings/euc_jis_2004.py +39 -0
  229. package/python/lib/python3.13/encodings/euc_jisx0213.py +39 -0
  230. package/python/lib/python3.13/encodings/euc_jp.py +39 -0
  231. package/python/lib/python3.13/encodings/euc_kr.py +39 -0
  232. package/python/lib/python3.13/encodings/gb18030.py +39 -0
  233. package/python/lib/python3.13/encodings/gb2312.py +39 -0
  234. package/python/lib/python3.13/encodings/gbk.py +39 -0
  235. package/python/lib/python3.13/encodings/hex_codec.py +55 -0
  236. package/python/lib/python3.13/encodings/hp_roman8.py +314 -0
  237. package/python/lib/python3.13/encodings/hz.py +39 -0
  238. package/python/lib/python3.13/encodings/idna.py +387 -0
  239. package/python/lib/python3.13/encodings/iso2022_jp.py +39 -0
  240. package/python/lib/python3.13/encodings/iso2022_jp_1.py +39 -0
  241. package/python/lib/python3.13/encodings/iso2022_jp_2.py +39 -0
  242. package/python/lib/python3.13/encodings/iso2022_jp_2004.py +39 -0
  243. package/python/lib/python3.13/encodings/iso2022_jp_3.py +39 -0
  244. package/python/lib/python3.13/encodings/iso2022_jp_ext.py +39 -0
  245. package/python/lib/python3.13/encodings/iso2022_kr.py +39 -0
  246. package/python/lib/python3.13/encodings/iso8859_1.py +307 -0
  247. package/python/lib/python3.13/encodings/iso8859_10.py +307 -0
  248. package/python/lib/python3.13/encodings/iso8859_11.py +307 -0
  249. package/python/lib/python3.13/encodings/iso8859_13.py +307 -0
  250. package/python/lib/python3.13/encodings/iso8859_14.py +307 -0
  251. package/python/lib/python3.13/encodings/iso8859_15.py +307 -0
  252. package/python/lib/python3.13/encodings/iso8859_16.py +307 -0
  253. package/python/lib/python3.13/encodings/iso8859_2.py +307 -0
  254. package/python/lib/python3.13/encodings/iso8859_3.py +307 -0
  255. package/python/lib/python3.13/encodings/iso8859_4.py +307 -0
  256. package/python/lib/python3.13/encodings/iso8859_5.py +307 -0
  257. package/python/lib/python3.13/encodings/iso8859_6.py +307 -0
  258. package/python/lib/python3.13/encodings/iso8859_7.py +307 -0
  259. package/python/lib/python3.13/encodings/iso8859_8.py +307 -0
  260. package/python/lib/python3.13/encodings/iso8859_9.py +307 -0
  261. package/python/lib/python3.13/encodings/johab.py +39 -0
  262. package/python/lib/python3.13/encodings/koi8_r.py +307 -0
  263. package/python/lib/python3.13/encodings/koi8_t.py +308 -0
  264. package/python/lib/python3.13/encodings/koi8_u.py +307 -0
  265. package/python/lib/python3.13/encodings/kz1048.py +307 -0
  266. package/python/lib/python3.13/encodings/latin_1.py +50 -0
  267. package/python/lib/python3.13/encodings/mac_arabic.py +698 -0
  268. package/python/lib/python3.13/encodings/mac_croatian.py +307 -0
  269. package/python/lib/python3.13/encodings/mac_cyrillic.py +307 -0
  270. package/python/lib/python3.13/encodings/mac_farsi.py +307 -0
  271. package/python/lib/python3.13/encodings/mac_greek.py +307 -0
  272. package/python/lib/python3.13/encodings/mac_iceland.py +307 -0
  273. package/python/lib/python3.13/encodings/mac_latin2.py +312 -0
  274. package/python/lib/python3.13/encodings/mac_roman.py +307 -0
  275. package/python/lib/python3.13/encodings/mac_romanian.py +307 -0
  276. package/python/lib/python3.13/encodings/mac_turkish.py +307 -0
  277. package/python/lib/python3.13/encodings/mbcs.py +47 -0
  278. package/python/lib/python3.13/encodings/oem.py +41 -0
  279. package/python/lib/python3.13/encodings/palmos.py +308 -0
  280. package/python/lib/python3.13/encodings/ptcp154.py +312 -0
  281. package/python/lib/python3.13/encodings/punycode.py +253 -0
  282. package/python/lib/python3.13/encodings/quopri_codec.py +56 -0
  283. package/python/lib/python3.13/encodings/raw_unicode_escape.py +46 -0
  284. package/python/lib/python3.13/encodings/rot_13.py +113 -0
  285. package/python/lib/python3.13/encodings/shift_jis.py +39 -0
  286. package/python/lib/python3.13/encodings/shift_jis_2004.py +39 -0
  287. package/python/lib/python3.13/encodings/shift_jisx0213.py +39 -0
  288. package/python/lib/python3.13/encodings/tis_620.py +307 -0
  289. package/python/lib/python3.13/encodings/undefined.py +49 -0
  290. package/python/lib/python3.13/encodings/unicode_escape.py +46 -0
  291. package/python/lib/python3.13/encodings/utf_16.py +155 -0
  292. package/python/lib/python3.13/encodings/utf_16_be.py +42 -0
  293. package/python/lib/python3.13/encodings/utf_16_le.py +42 -0
  294. package/python/lib/python3.13/encodings/utf_32.py +150 -0
  295. package/python/lib/python3.13/encodings/utf_32_be.py +37 -0
  296. package/python/lib/python3.13/encodings/utf_32_le.py +37 -0
  297. package/python/lib/python3.13/encodings/utf_7.py +38 -0
  298. package/python/lib/python3.13/encodings/utf_8.py +42 -0
  299. package/python/lib/python3.13/encodings/utf_8_sig.py +130 -0
  300. package/python/lib/python3.13/encodings/uu_codec.py +103 -0
  301. package/python/lib/python3.13/encodings/zlib_codec.py +77 -0
  302. package/python/lib/python3.13/enum.py +2183 -0
  303. package/python/lib/python3.13/filecmp.py +320 -0
  304. package/python/lib/python3.13/fileinput.py +442 -0
  305. package/python/lib/python3.13/fnmatch.py +192 -0
  306. package/python/lib/python3.13/fractions.py +1043 -0
  307. package/python/lib/python3.13/ftplib.py +975 -0
  308. package/python/lib/python3.13/functools.py +1036 -0
  309. package/python/lib/python3.13/genericpath.py +200 -0
  310. package/python/lib/python3.13/getopt.py +215 -0
  311. package/python/lib/python3.13/getpass.py +192 -0
  312. package/python/lib/python3.13/gettext.py +657 -0
  313. package/python/lib/python3.13/glob.py +572 -0
  314. package/python/lib/python3.13/graphlib.py +250 -0
  315. package/python/lib/python3.13/gzip.py +693 -0
  316. package/python/lib/python3.13/hashlib.py +255 -0
  317. package/python/lib/python3.13/heapq.py +603 -0
  318. package/python/lib/python3.13/hmac.py +220 -0
  319. package/python/lib/python3.13/html/__init__.py +132 -0
  320. package/python/lib/python3.13/html/entities.py +2513 -0
  321. package/python/lib/python3.13/html/parser.py +583 -0
  322. package/python/lib/python3.13/http/__init__.py +202 -0
  323. package/python/lib/python3.13/http/client.py +1598 -0
  324. package/python/lib/python3.13/http/cookiejar.py +2122 -0
  325. package/python/lib/python3.13/http/cookies.py +635 -0
  326. package/python/lib/python3.13/http/server.py +1355 -0
  327. package/python/lib/python3.13/imaplib.py +1769 -0
  328. package/python/lib/python3.13/importlib/__init__.py +136 -0
  329. package/python/lib/python3.13/importlib/_abc.py +39 -0
  330. package/python/lib/python3.13/importlib/_bootstrap.py +1559 -0
  331. package/python/lib/python3.13/importlib/_bootstrap_external.py +1826 -0
  332. package/python/lib/python3.13/importlib/abc.py +243 -0
  333. package/python/lib/python3.13/importlib/machinery.py +21 -0
  334. package/python/lib/python3.13/importlib/metadata/__init__.py +1093 -0
  335. package/python/lib/python3.13/importlib/metadata/_adapters.py +89 -0
  336. package/python/lib/python3.13/importlib/metadata/_collections.py +30 -0
  337. package/python/lib/python3.13/importlib/metadata/_functools.py +104 -0
  338. package/python/lib/python3.13/importlib/metadata/_itertools.py +73 -0
  339. package/python/lib/python3.13/importlib/metadata/_meta.py +67 -0
  340. package/python/lib/python3.13/importlib/metadata/_text.py +99 -0
  341. package/python/lib/python3.13/importlib/metadata/diagnose.py +21 -0
  342. package/python/lib/python3.13/importlib/readers.py +12 -0
  343. package/python/lib/python3.13/importlib/resources/__init__.py +43 -0
  344. package/python/lib/python3.13/importlib/resources/_adapters.py +168 -0
  345. package/python/lib/python3.13/importlib/resources/_common.py +211 -0
  346. package/python/lib/python3.13/importlib/resources/_functional.py +81 -0
  347. package/python/lib/python3.13/importlib/resources/_itertools.py +38 -0
  348. package/python/lib/python3.13/importlib/resources/abc.py +173 -0
  349. package/python/lib/python3.13/importlib/resources/readers.py +203 -0
  350. package/python/lib/python3.13/importlib/resources/simple.py +106 -0
  351. package/python/lib/python3.13/importlib/simple.py +14 -0
  352. package/python/lib/python3.13/importlib/util.py +274 -0
  353. package/python/lib/python3.13/inspect.py +3479 -0
  354. package/python/lib/python3.13/io.py +99 -0
  355. package/python/lib/python3.13/ipaddress.py +2440 -0
  356. package/python/lib/python3.13/json/__init__.py +365 -0
  357. package/python/lib/python3.13/json/decoder.py +364 -0
  358. package/python/lib/python3.13/json/encoder.py +446 -0
  359. package/python/lib/python3.13/json/scanner.py +73 -0
  360. package/python/lib/python3.13/json/tool.py +90 -0
  361. package/python/lib/python3.13/keyword.py +64 -0
  362. package/python/lib/python3.13/lib-dynload/.empty +0 -0
  363. package/python/lib/python3.13/lib-dynload/_dbm.cpython-313-x86_64-linux-gnu.so +0 -0
  364. package/python/lib/python3.13/linecache.py +236 -0
  365. package/python/lib/python3.13/locale.py +1987 -0
  366. package/python/lib/python3.13/logging/__init__.py +2330 -0
  367. package/python/lib/python3.13/logging/config.py +1080 -0
  368. package/python/lib/python3.13/logging/handlers.py +1629 -0
  369. package/python/lib/python3.13/lzma.py +364 -0
  370. package/python/lib/python3.13/mailbox.py +2219 -0
  371. package/python/lib/python3.13/mimetypes.py +679 -0
  372. package/python/lib/python3.13/modulefinder.py +671 -0
  373. package/python/lib/python3.13/multiprocessing/__init__.py +37 -0
  374. package/python/lib/python3.13/multiprocessing/connection.py +1216 -0
  375. package/python/lib/python3.13/multiprocessing/context.py +383 -0
  376. package/python/lib/python3.13/multiprocessing/dummy/__init__.py +126 -0
  377. package/python/lib/python3.13/multiprocessing/dummy/connection.py +75 -0
  378. package/python/lib/python3.13/multiprocessing/forkserver.py +373 -0
  379. package/python/lib/python3.13/multiprocessing/heap.py +337 -0
  380. package/python/lib/python3.13/multiprocessing/managers.py +1397 -0
  381. package/python/lib/python3.13/multiprocessing/pool.py +957 -0
  382. package/python/lib/python3.13/multiprocessing/popen_fork.py +97 -0
  383. package/python/lib/python3.13/multiprocessing/popen_forkserver.py +74 -0
  384. package/python/lib/python3.13/multiprocessing/popen_spawn_posix.py +76 -0
  385. package/python/lib/python3.13/multiprocessing/popen_spawn_win32.py +147 -0
  386. package/python/lib/python3.13/multiprocessing/process.py +436 -0
  387. package/python/lib/python3.13/multiprocessing/queues.py +399 -0
  388. package/python/lib/python3.13/multiprocessing/reduction.py +281 -0
  389. package/python/lib/python3.13/multiprocessing/resource_sharer.py +154 -0
  390. package/python/lib/python3.13/multiprocessing/resource_tracker.py +499 -0
  391. package/python/lib/python3.13/multiprocessing/shared_memory.py +544 -0
  392. package/python/lib/python3.13/multiprocessing/sharedctypes.py +240 -0
  393. package/python/lib/python3.13/multiprocessing/spawn.py +307 -0
  394. package/python/lib/python3.13/multiprocessing/synchronize.py +404 -0
  395. package/python/lib/python3.13/multiprocessing/util.py +562 -0
  396. package/python/lib/python3.13/netrc.py +199 -0
  397. package/python/lib/python3.13/ntpath.py +872 -0
  398. package/python/lib/python3.13/nturl2path.py +69 -0
  399. package/python/lib/python3.13/numbers.py +427 -0
  400. package/python/lib/python3.13/opcode.py +115 -0
  401. package/python/lib/python3.13/operator.py +467 -0
  402. package/python/lib/python3.13/optparse.py +1681 -0
  403. package/python/lib/python3.13/os.py +1184 -0
  404. package/python/lib/python3.13/pathlib/__init__.py +12 -0
  405. package/python/lib/python3.13/pathlib/_abc.py +930 -0
  406. package/python/lib/python3.13/pathlib/_local.py +861 -0
  407. package/python/lib/python3.13/pdb.py +2550 -0
  408. package/python/lib/python3.13/pickle.py +1860 -0
  409. package/python/lib/python3.13/pickletools.py +2904 -0
  410. package/python/lib/python3.13/pkgutil.py +529 -0
  411. package/python/lib/python3.13/platform.py +1454 -0
  412. package/python/lib/python3.13/plistlib.py +948 -0
  413. package/python/lib/python3.13/poplib.py +477 -0
  414. package/python/lib/python3.13/posixpath.py +578 -0
  415. package/python/lib/python3.13/pprint.py +658 -0
  416. package/python/lib/python3.13/profile.py +616 -0
  417. package/python/lib/python3.13/pstats.py +778 -0
  418. package/python/lib/python3.13/pty.py +211 -0
  419. package/python/lib/python3.13/py_compile.py +212 -0
  420. package/python/lib/python3.13/pyclbr.py +314 -0
  421. package/python/lib/python3.13/pydoc.py +2861 -0
  422. package/python/lib/python3.13/queue.py +383 -0
  423. package/python/lib/python3.13/quopri.py +237 -0
  424. package/python/lib/python3.13/random.py +1078 -0
  425. package/python/lib/python3.13/re/__init__.py +428 -0
  426. package/python/lib/python3.13/re/_casefix.py +106 -0
  427. package/python/lib/python3.13/re/_compiler.py +768 -0
  428. package/python/lib/python3.13/re/_constants.py +222 -0
  429. package/python/lib/python3.13/re/_parser.py +1081 -0
  430. package/python/lib/python3.13/reprlib.py +230 -0
  431. package/python/lib/python3.13/rlcompleter.py +222 -0
  432. package/python/lib/python3.13/runpy.py +326 -0
  433. package/python/lib/python3.13/sched.py +167 -0
  434. package/python/lib/python3.13/secrets.py +71 -0
  435. package/python/lib/python3.13/selectors.py +603 -0
  436. package/python/lib/python3.13/shelve.py +250 -0
  437. package/python/lib/python3.13/shlex.py +345 -0
  438. package/python/lib/python3.13/shutil.py +1569 -0
  439. package/python/lib/python3.13/signal.py +94 -0
  440. package/python/lib/python3.13/site.py +773 -0
  441. package/python/lib/python3.13/smtplib.py +1123 -0
  442. package/python/lib/python3.13/socket.py +988 -0
  443. package/python/lib/python3.13/socketserver.py +863 -0
  444. package/python/lib/python3.13/sqlite3/__init__.py +70 -0
  445. package/python/lib/python3.13/sqlite3/__main__.py +139 -0
  446. package/python/lib/python3.13/sqlite3/dbapi2.py +108 -0
  447. package/python/lib/python3.13/sqlite3/dump.py +118 -0
  448. package/python/lib/python3.13/sre_compile.py +7 -0
  449. package/python/lib/python3.13/sre_constants.py +7 -0
  450. package/python/lib/python3.13/sre_parse.py +7 -0
  451. package/python/lib/python3.13/ssl.py +1541 -0
  452. package/python/lib/python3.13/stat.py +212 -0
  453. package/python/lib/python3.13/statistics.py +1817 -0
  454. package/python/lib/python3.13/string.py +314 -0
  455. package/python/lib/python3.13/stringprep.py +272 -0
  456. package/python/lib/python3.13/struct.py +15 -0
  457. package/python/lib/python3.13/subprocess.py +2258 -0
  458. package/python/lib/python3.13/symtable.py +414 -0
  459. package/python/lib/python3.13/sysconfig/__init__.py +734 -0
  460. package/python/lib/python3.13/sysconfig/__main__.py +248 -0
  461. package/python/lib/python3.13/tabnanny.py +340 -0
  462. package/python/lib/python3.13/tarfile.py +3136 -0
  463. package/python/lib/python3.13/tempfile.py +958 -0
  464. package/python/lib/python3.13/textwrap.py +497 -0
  465. package/python/lib/python3.13/this.py +28 -0
  466. package/python/lib/python3.13/threading.py +1602 -0
  467. package/python/lib/python3.13/timeit.py +381 -0
  468. package/python/lib/python3.13/token.py +141 -0
  469. package/python/lib/python3.13/tokenize.py +592 -0
  470. package/python/lib/python3.13/tomllib/__init__.py +10 -0
  471. package/python/lib/python3.13/tomllib/_parser.py +703 -0
  472. package/python/lib/python3.13/tomllib/_re.py +107 -0
  473. package/python/lib/python3.13/tomllib/_types.py +10 -0
  474. package/python/lib/python3.13/tomllib/mypy.ini +15 -0
  475. package/python/lib/python3.13/trace.py +754 -0
  476. package/python/lib/python3.13/traceback.py +1639 -0
  477. package/python/lib/python3.13/tracemalloc.py +560 -0
  478. package/python/lib/python3.13/tty.py +73 -0
  479. package/python/lib/python3.13/types.py +346 -0
  480. package/python/lib/python3.13/typing.py +3846 -0
  481. package/python/lib/python3.13/unittest/__init__.py +80 -0
  482. package/python/lib/python3.13/unittest/__main__.py +18 -0
  483. package/python/lib/python3.13/unittest/_log.py +86 -0
  484. package/python/lib/python3.13/unittest/async_case.py +146 -0
  485. package/python/lib/python3.13/unittest/case.py +1478 -0
  486. package/python/lib/python3.13/unittest/loader.py +460 -0
  487. package/python/lib/python3.13/unittest/main.py +280 -0
  488. package/python/lib/python3.13/unittest/mock.py +3189 -0
  489. package/python/lib/python3.13/unittest/result.py +256 -0
  490. package/python/lib/python3.13/unittest/runner.py +292 -0
  491. package/python/lib/python3.13/unittest/signals.py +71 -0
  492. package/python/lib/python3.13/unittest/suite.py +379 -0
  493. package/python/lib/python3.13/unittest/util.py +170 -0
  494. package/python/lib/python3.13/urllib/__init__.py +0 -0
  495. package/python/lib/python3.13/urllib/error.py +74 -0
  496. package/python/lib/python3.13/urllib/parse.py +1264 -0
  497. package/python/lib/python3.13/urllib/request.py +2796 -0
  498. package/python/lib/python3.13/urllib/response.py +84 -0
  499. package/python/lib/python3.13/urllib/robotparser.py +363 -0
  500. package/python/lib/python3.13/uuid.py +784 -0
  501. package/python/lib/python3.13/warnings.py +735 -0
  502. package/python/lib/python3.13/wave.py +665 -0
  503. package/python/lib/python3.13/weakref.py +674 -0
  504. package/python/lib/python3.13/webbrowser.py +724 -0
  505. package/python/lib/python3.13/wsgiref/__init__.py +25 -0
  506. package/python/lib/python3.13/wsgiref/handlers.py +575 -0
  507. package/python/lib/python3.13/wsgiref/headers.py +192 -0
  508. package/python/lib/python3.13/wsgiref/simple_server.py +161 -0
  509. package/python/lib/python3.13/wsgiref/types.py +54 -0
  510. package/python/lib/python3.13/wsgiref/util.py +159 -0
  511. package/python/lib/python3.13/wsgiref/validate.py +438 -0
  512. package/python/lib/python3.13/xml/__init__.py +20 -0
  513. package/python/lib/python3.13/xml/dom/NodeFilter.py +27 -0
  514. package/python/lib/python3.13/xml/dom/__init__.py +140 -0
  515. package/python/lib/python3.13/xml/dom/domreg.py +99 -0
  516. package/python/lib/python3.13/xml/dom/expatbuilder.py +962 -0
  517. package/python/lib/python3.13/xml/dom/minicompat.py +109 -0
  518. package/python/lib/python3.13/xml/dom/minidom.py +2024 -0
  519. package/python/lib/python3.13/xml/dom/pulldom.py +336 -0
  520. package/python/lib/python3.13/xml/dom/xmlbuilder.py +389 -0
  521. package/python/lib/python3.13/xml/etree/ElementInclude.py +186 -0
  522. package/python/lib/python3.13/xml/etree/ElementPath.py +430 -0
  523. package/python/lib/python3.13/xml/etree/ElementTree.py +2116 -0
  524. package/python/lib/python3.13/xml/etree/__init__.py +33 -0
  525. package/python/lib/python3.13/xml/etree/cElementTree.py +3 -0
  526. package/python/lib/python3.13/xml/parsers/__init__.py +8 -0
  527. package/python/lib/python3.13/xml/parsers/expat.py +8 -0
  528. package/python/lib/python3.13/xml/sax/__init__.py +94 -0
  529. package/python/lib/python3.13/xml/sax/_exceptions.py +127 -0
  530. package/python/lib/python3.13/xml/sax/expatreader.py +454 -0
  531. package/python/lib/python3.13/xml/sax/handler.py +387 -0
  532. package/python/lib/python3.13/xml/sax/saxutils.py +369 -0
  533. package/python/lib/python3.13/xml/sax/xmlreader.py +378 -0
  534. package/python/lib/python3.13/xmlrpc/__init__.py +1 -0
  535. package/python/lib/python3.13/xmlrpc/client.py +1503 -0
  536. package/python/lib/python3.13/xmlrpc/server.py +1002 -0
  537. package/python/lib/python3.13/zipapp.py +229 -0
  538. package/python/lib/python3.13/zipfile/__init__.py +2391 -0
  539. package/python/lib/python3.13/zipfile/__main__.py +4 -0
  540. package/python/lib/python3.13/zipfile/_path/__init__.py +452 -0
  541. package/python/lib/python3.13/zipfile/_path/glob.py +113 -0
  542. package/python/lib/python3.13/zipimport.py +803 -0
  543. package/python/lib/python3.13/zoneinfo/__init__.py +34 -0
  544. package/python/lib/python3.13/zoneinfo/_common.py +172 -0
  545. package/python/lib/python3.13/zoneinfo/_tzpath.py +189 -0
  546. package/python/lib/python3.13/zoneinfo/_zoneinfo.py +779 -0
  547. package/python/licenses/LICENSE.bdb.txt +126 -0
  548. package/python/licenses/LICENSE.bzip2.txt +37 -0
  549. package/python/licenses/LICENSE.cpython.txt +771 -0
  550. package/python/licenses/LICENSE.expat.txt +21 -0
  551. package/python/licenses/LICENSE.libX11.txt +942 -0
  552. package/python/licenses/LICENSE.libXau.txt +21 -0
  553. package/python/licenses/LICENSE.libedit.txt +29 -0
  554. package/python/licenses/LICENSE.libffi.txt +21 -0
  555. package/python/licenses/LICENSE.liblzma.txt +13 -0
  556. package/python/licenses/LICENSE.libuuid.txt +27 -0
  557. package/python/licenses/LICENSE.libxcb.txt +30 -0
  558. package/python/licenses/LICENSE.mpdecimal.txt +24 -0
  559. package/python/licenses/LICENSE.ncurses.txt +29 -0
  560. package/python/licenses/LICENSE.openssl-1.1.txt +124 -0
  561. package/python/licenses/LICENSE.openssl-3.txt +177 -0
  562. package/python/licenses/LICENSE.sqlite.txt +23 -0
  563. package/python/licenses/LICENSE.tcl.txt +40 -0
  564. package/python/licenses/LICENSE.tix.txt +54 -0
  565. package/python/licenses/LICENSE.zlib.txt +21 -0
@@ -0,0 +1,892 @@
1
+ # Copyright 2009 Brian Quinlan. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Implements ProcessPoolExecutor.
5
+
6
+ The following diagram and text describe the data-flow through the system:
7
+
8
+ |======================= In-process =====================|== Out-of-process ==|
9
+
10
+ +----------+ +----------+ +--------+ +-----------+ +---------+
11
+ | | => | Work Ids | | | | Call Q | | Process |
12
+ | | +----------+ | | +-----------+ | Pool |
13
+ | | | ... | | | | ... | +---------+
14
+ | | | 6 | => | | => | 5, call() | => | |
15
+ | | | 7 | | | | ... | | |
16
+ | Process | | ... | | Local | +-----------+ | Process |
17
+ | Pool | +----------+ | Worker | | #1..n |
18
+ | Executor | | Thread | | |
19
+ | | +----------- + | | +-----------+ | |
20
+ | | <=> | Work Items | <=> | | <= | Result Q | <= | |
21
+ | | +------------+ | | +-----------+ | |
22
+ | | | 6: call() | | | | ... | | |
23
+ | | | future | | | | 4, result | | |
24
+ | | | ... | | | | 3, except | | |
25
+ +----------+ +------------+ +--------+ +-----------+ +---------+
26
+
27
+ Executor.submit() called:
28
+ - creates a uniquely numbered _WorkItem and adds it to the "Work Items" dict
29
+ - adds the id of the _WorkItem to the "Work Ids" queue
30
+
31
+ Local worker thread:
32
+ - reads work ids from the "Work Ids" queue and looks up the corresponding
33
+ WorkItem from the "Work Items" dict: if the work item has been cancelled then
34
+ it is simply removed from the dict, otherwise it is repackaged as a
35
+ _CallItem and put in the "Call Q". New _CallItems are put in the "Call Q"
36
+ until "Call Q" is full. NOTE: the size of the "Call Q" is kept small because
37
+ calls placed in the "Call Q" can no longer be cancelled with Future.cancel().
38
+ - reads _ResultItems from "Result Q", updates the future stored in the
39
+ "Work Items" dict and deletes the dict entry
40
+
41
+ Process #1..n:
42
+ - reads _CallItems from "Call Q", executes the calls, and puts the resulting
43
+ _ResultItems in "Result Q"
44
+ """
45
+
46
+ __author__ = 'Brian Quinlan (brian@sweetapp.com)'
47
+
48
+ import os
49
+ from concurrent.futures import _base
50
+ import queue
51
+ import multiprocessing as mp
52
+ # This import is required to load the multiprocessing.connection submodule
53
+ # so that it can be accessed later as `mp.connection`
54
+ import multiprocessing.connection
55
+ from multiprocessing.queues import Queue
56
+ import threading
57
+ import weakref
58
+ from functools import partial
59
+ import itertools
60
+ import sys
61
+ from traceback import format_exception
62
+
63
+
64
+ _threads_wakeups = weakref.WeakKeyDictionary()
65
+ _global_shutdown = False
66
+
67
+
68
+ class _ThreadWakeup:
69
+ def __init__(self):
70
+ self._closed = False
71
+ self._lock = threading.Lock()
72
+ self._reader, self._writer = mp.Pipe(duplex=False)
73
+
74
+ def close(self):
75
+ # Please note that we do not take the self._lock when
76
+ # calling clear() (to avoid deadlocking) so this method can
77
+ # only be called safely from the same thread as all calls to
78
+ # clear() even if you hold the lock. Otherwise we
79
+ # might try to read from the closed pipe.
80
+ with self._lock:
81
+ if not self._closed:
82
+ self._closed = True
83
+ self._writer.close()
84
+ self._reader.close()
85
+
86
+ def wakeup(self):
87
+ with self._lock:
88
+ if not self._closed:
89
+ self._writer.send_bytes(b"")
90
+
91
+ def clear(self):
92
+ if self._closed:
93
+ raise RuntimeError('operation on closed _ThreadWakeup')
94
+ while self._reader.poll():
95
+ self._reader.recv_bytes()
96
+
97
+
98
+ def _python_exit():
99
+ global _global_shutdown
100
+ _global_shutdown = True
101
+ items = list(_threads_wakeups.items())
102
+ for _, thread_wakeup in items:
103
+ # call not protected by ProcessPoolExecutor._shutdown_lock
104
+ thread_wakeup.wakeup()
105
+ for t, _ in items:
106
+ t.join()
107
+
108
+ # Register for `_python_exit()` to be called just before joining all
109
+ # non-daemon threads. This is used instead of `atexit.register()` for
110
+ # compatibility with subinterpreters, which no longer support daemon threads.
111
+ # See bpo-39812 for context.
112
+ threading._register_atexit(_python_exit)
113
+
114
+ # Controls how many more calls than processes will be queued in the call queue.
115
+ # A smaller number will mean that processes spend more time idle waiting for
116
+ # work while a larger number will make Future.cancel() succeed less frequently
117
+ # (Futures in the call queue cannot be cancelled).
118
+ EXTRA_QUEUED_CALLS = 1
119
+
120
+
121
+ # On Windows, WaitForMultipleObjects is used to wait for processes to finish.
122
+ # It can wait on, at most, 63 objects. There is an overhead of two objects:
123
+ # - the result queue reader
124
+ # - the thread wakeup reader
125
+ _MAX_WINDOWS_WORKERS = 63 - 2
126
+
127
+ # Hack to embed stringification of remote traceback in local traceback
128
+
129
+ class _RemoteTraceback(Exception):
130
+ def __init__(self, tb):
131
+ self.tb = tb
132
+ def __str__(self):
133
+ return self.tb
134
+
135
+ class _ExceptionWithTraceback:
136
+ def __init__(self, exc, tb):
137
+ tb = ''.join(format_exception(type(exc), exc, tb))
138
+ self.exc = exc
139
+ # Traceback object needs to be garbage-collected as its frames
140
+ # contain references to all the objects in the exception scope
141
+ self.exc.__traceback__ = None
142
+ self.tb = '\n"""\n%s"""' % tb
143
+ def __reduce__(self):
144
+ return _rebuild_exc, (self.exc, self.tb)
145
+
146
+ def _rebuild_exc(exc, tb):
147
+ exc.__cause__ = _RemoteTraceback(tb)
148
+ return exc
149
+
150
+ class _WorkItem(object):
151
+ def __init__(self, future, fn, args, kwargs):
152
+ self.future = future
153
+ self.fn = fn
154
+ self.args = args
155
+ self.kwargs = kwargs
156
+
157
+ class _ResultItem(object):
158
+ def __init__(self, work_id, exception=None, result=None, exit_pid=None):
159
+ self.work_id = work_id
160
+ self.exception = exception
161
+ self.result = result
162
+ self.exit_pid = exit_pid
163
+
164
+ class _CallItem(object):
165
+ def __init__(self, work_id, fn, args, kwargs):
166
+ self.work_id = work_id
167
+ self.fn = fn
168
+ self.args = args
169
+ self.kwargs = kwargs
170
+
171
+
172
+ class _SafeQueue(Queue):
173
+ """Safe Queue set exception to the future object linked to a job"""
174
+ def __init__(self, max_size=0, *, ctx, pending_work_items, thread_wakeup):
175
+ self.pending_work_items = pending_work_items
176
+ self.thread_wakeup = thread_wakeup
177
+ super().__init__(max_size, ctx=ctx)
178
+
179
+ def _on_queue_feeder_error(self, e, obj):
180
+ if isinstance(obj, _CallItem):
181
+ tb = format_exception(type(e), e, e.__traceback__)
182
+ e.__cause__ = _RemoteTraceback('\n"""\n{}"""'.format(''.join(tb)))
183
+ work_item = self.pending_work_items.pop(obj.work_id, None)
184
+ self.thread_wakeup.wakeup()
185
+ # work_item can be None if another process terminated. In this
186
+ # case, the executor_manager_thread fails all work_items
187
+ # with BrokenProcessPool
188
+ if work_item is not None:
189
+ work_item.future.set_exception(e)
190
+ else:
191
+ super()._on_queue_feeder_error(e, obj)
192
+
193
+
194
+ def _process_chunk(fn, chunk):
195
+ """ Processes a chunk of an iterable passed to map.
196
+
197
+ Runs the function passed to map() on a chunk of the
198
+ iterable passed to map.
199
+
200
+ This function is run in a separate process.
201
+
202
+ """
203
+ return [fn(*args) for args in chunk]
204
+
205
+
206
+ def _sendback_result(result_queue, work_id, result=None, exception=None,
207
+ exit_pid=None):
208
+ """Safely send back the given result or exception"""
209
+ try:
210
+ result_queue.put(_ResultItem(work_id, result=result,
211
+ exception=exception, exit_pid=exit_pid))
212
+ except BaseException as e:
213
+ exc = _ExceptionWithTraceback(e, e.__traceback__)
214
+ result_queue.put(_ResultItem(work_id, exception=exc,
215
+ exit_pid=exit_pid))
216
+
217
+
218
+ def _process_worker(call_queue, result_queue, initializer, initargs, max_tasks=None):
219
+ """Evaluates calls from call_queue and places the results in result_queue.
220
+
221
+ This worker is run in a separate process.
222
+
223
+ Args:
224
+ call_queue: A ctx.Queue of _CallItems that will be read and
225
+ evaluated by the worker.
226
+ result_queue: A ctx.Queue of _ResultItems that will written
227
+ to by the worker.
228
+ initializer: A callable initializer, or None
229
+ initargs: A tuple of args for the initializer
230
+ """
231
+ if initializer is not None:
232
+ try:
233
+ initializer(*initargs)
234
+ except BaseException:
235
+ _base.LOGGER.critical('Exception in initializer:', exc_info=True)
236
+ # The parent will notice that the process stopped and
237
+ # mark the pool broken
238
+ return
239
+ num_tasks = 0
240
+ exit_pid = None
241
+ while True:
242
+ call_item = call_queue.get(block=True)
243
+ if call_item is None:
244
+ # Wake up queue management thread
245
+ result_queue.put(os.getpid())
246
+ return
247
+
248
+ if max_tasks is not None:
249
+ num_tasks += 1
250
+ if num_tasks >= max_tasks:
251
+ exit_pid = os.getpid()
252
+
253
+ try:
254
+ r = call_item.fn(*call_item.args, **call_item.kwargs)
255
+ except BaseException as e:
256
+ exc = _ExceptionWithTraceback(e, e.__traceback__)
257
+ _sendback_result(result_queue, call_item.work_id, exception=exc,
258
+ exit_pid=exit_pid)
259
+ else:
260
+ _sendback_result(result_queue, call_item.work_id, result=r,
261
+ exit_pid=exit_pid)
262
+ del r
263
+
264
+ # Liberate the resource as soon as possible, to avoid holding onto
265
+ # open files or shared memory that is not needed anymore
266
+ del call_item
267
+
268
+ if exit_pid is not None:
269
+ return
270
+
271
+
272
+ class _ExecutorManagerThread(threading.Thread):
273
+ """Manages the communication between this process and the worker processes.
274
+
275
+ The manager is run in a local thread.
276
+
277
+ Args:
278
+ executor: A reference to the ProcessPoolExecutor that owns
279
+ this thread. A weakref will be own by the manager as well as
280
+ references to internal objects used to introspect the state of
281
+ the executor.
282
+ """
283
+
284
+ def __init__(self, executor):
285
+ # Store references to necessary internals of the executor.
286
+
287
+ # A _ThreadWakeup to allow waking up the queue_manager_thread from the
288
+ # main Thread and avoid deadlocks caused by permanently locked queues.
289
+ self.thread_wakeup = executor._executor_manager_thread_wakeup
290
+ self.shutdown_lock = executor._shutdown_lock
291
+
292
+ # A weakref.ref to the ProcessPoolExecutor that owns this thread. Used
293
+ # to determine if the ProcessPoolExecutor has been garbage collected
294
+ # and that the manager can exit.
295
+ # When the executor gets garbage collected, the weakref callback
296
+ # will wake up the queue management thread so that it can terminate
297
+ # if there is no pending work item.
298
+ def weakref_cb(_,
299
+ thread_wakeup=self.thread_wakeup,
300
+ mp_util_debug=mp.util.debug):
301
+ mp_util_debug('Executor collected: triggering callback for'
302
+ ' QueueManager wakeup')
303
+ thread_wakeup.wakeup()
304
+
305
+ self.executor_reference = weakref.ref(executor, weakref_cb)
306
+
307
+ # A list of the ctx.Process instances used as workers.
308
+ self.processes = executor._processes
309
+
310
+ # A ctx.Queue that will be filled with _CallItems derived from
311
+ # _WorkItems for processing by the process workers.
312
+ self.call_queue = executor._call_queue
313
+
314
+ # A ctx.SimpleQueue of _ResultItems generated by the process workers.
315
+ self.result_queue = executor._result_queue
316
+
317
+ # A queue.Queue of work ids e.g. Queue([5, 6, ...]).
318
+ self.work_ids_queue = executor._work_ids
319
+
320
+ # Maximum number of tasks a worker process can execute before
321
+ # exiting safely
322
+ self.max_tasks_per_child = executor._max_tasks_per_child
323
+
324
+ # A dict mapping work ids to _WorkItems e.g.
325
+ # {5: <_WorkItem...>, 6: <_WorkItem...>, ...}
326
+ self.pending_work_items = executor._pending_work_items
327
+
328
+ super().__init__()
329
+
330
+ def run(self):
331
+ # Main loop for the executor manager thread.
332
+
333
+ while True:
334
+ # gh-109047: During Python finalization, self.call_queue.put()
335
+ # creation of a thread can fail with RuntimeError.
336
+ try:
337
+ self.add_call_item_to_queue()
338
+ except BaseException as exc:
339
+ cause = format_exception(exc)
340
+ self.terminate_broken(cause)
341
+ return
342
+
343
+ result_item, is_broken, cause = self.wait_result_broken_or_wakeup()
344
+
345
+ if is_broken:
346
+ self.terminate_broken(cause)
347
+ return
348
+ if result_item is not None:
349
+ self.process_result_item(result_item)
350
+
351
+ process_exited = result_item.exit_pid is not None
352
+ if process_exited:
353
+ p = self.processes.pop(result_item.exit_pid)
354
+ p.join()
355
+
356
+ # Delete reference to result_item to avoid keeping references
357
+ # while waiting on new results.
358
+ del result_item
359
+
360
+ if executor := self.executor_reference():
361
+ if process_exited:
362
+ with self.shutdown_lock:
363
+ executor._replace_dead_worker()
364
+ else:
365
+ executor._idle_worker_semaphore.release()
366
+ del executor
367
+
368
+ if self.is_shutting_down():
369
+ self.flag_executor_shutting_down()
370
+
371
+ # When only canceled futures remain in pending_work_items, our
372
+ # next call to wait_result_broken_or_wakeup would hang forever.
373
+ # This makes sure we have some running futures or none at all.
374
+ self.add_call_item_to_queue()
375
+
376
+ # Since no new work items can be added, it is safe to shutdown
377
+ # this thread if there are no pending work items.
378
+ if not self.pending_work_items:
379
+ self.join_executor_internals()
380
+ return
381
+
382
+ def add_call_item_to_queue(self):
383
+ # Fills call_queue with _WorkItems from pending_work_items.
384
+ # This function never blocks.
385
+ while True:
386
+ if self.call_queue.full():
387
+ return
388
+ try:
389
+ work_id = self.work_ids_queue.get(block=False)
390
+ except queue.Empty:
391
+ return
392
+ else:
393
+ work_item = self.pending_work_items[work_id]
394
+
395
+ if work_item.future.set_running_or_notify_cancel():
396
+ self.call_queue.put(_CallItem(work_id,
397
+ work_item.fn,
398
+ work_item.args,
399
+ work_item.kwargs),
400
+ block=True)
401
+ else:
402
+ del self.pending_work_items[work_id]
403
+ continue
404
+
405
+ def wait_result_broken_or_wakeup(self):
406
+ # Wait for a result to be ready in the result_queue while checking
407
+ # that all worker processes are still running, or for a wake up
408
+ # signal send. The wake up signals come either from new tasks being
409
+ # submitted, from the executor being shutdown/gc-ed, or from the
410
+ # shutdown of the python interpreter.
411
+ result_reader = self.result_queue._reader
412
+ assert not self.thread_wakeup._closed
413
+ wakeup_reader = self.thread_wakeup._reader
414
+ readers = [result_reader, wakeup_reader]
415
+ worker_sentinels = [p.sentinel for p in list(self.processes.values())]
416
+ ready = mp.connection.wait(readers + worker_sentinels)
417
+
418
+ cause = None
419
+ is_broken = True
420
+ result_item = None
421
+ if result_reader in ready:
422
+ try:
423
+ result_item = result_reader.recv()
424
+ is_broken = False
425
+ except BaseException as exc:
426
+ cause = format_exception(exc)
427
+
428
+ elif wakeup_reader in ready:
429
+ is_broken = False
430
+
431
+ self.thread_wakeup.clear()
432
+
433
+ return result_item, is_broken, cause
434
+
435
+ def process_result_item(self, result_item):
436
+ # Process the received a result_item. This can be either the PID of a
437
+ # worker that exited gracefully or a _ResultItem
438
+
439
+ # Received a _ResultItem so mark the future as completed.
440
+ work_item = self.pending_work_items.pop(result_item.work_id, None)
441
+ # work_item can be None if another process terminated (see above)
442
+ if work_item is not None:
443
+ if result_item.exception is not None:
444
+ work_item.future.set_exception(result_item.exception)
445
+ else:
446
+ work_item.future.set_result(result_item.result)
447
+
448
+ def is_shutting_down(self):
449
+ # Check whether we should start shutting down the executor.
450
+ executor = self.executor_reference()
451
+ # No more work items can be added if:
452
+ # - The interpreter is shutting down OR
453
+ # - The executor that owns this worker has been collected OR
454
+ # - The executor that owns this worker has been shutdown.
455
+ return (_global_shutdown or executor is None
456
+ or executor._shutdown_thread)
457
+
458
+ def _terminate_broken(self, cause):
459
+ # Terminate the executor because it is in a broken state. The cause
460
+ # argument can be used to display more information on the error that
461
+ # lead the executor into becoming broken.
462
+
463
+ # Mark the process pool broken so that submits fail right now.
464
+ executor = self.executor_reference()
465
+ if executor is not None:
466
+ executor._broken = ('A child process terminated '
467
+ 'abruptly, the process pool is not '
468
+ 'usable anymore')
469
+ executor._shutdown_thread = True
470
+ executor = None
471
+
472
+ # All pending tasks are to be marked failed with a
473
+ # BrokenProcessPool error, as separate instances to avoid sharing
474
+ # a traceback (gh-101267).
475
+ cause_tb = None
476
+ if cause is not None:
477
+ cause_tb = f"\n'''\n{''.join(cause)}'''"
478
+
479
+ # Mark pending tasks as failed.
480
+ for work_id, work_item in self.pending_work_items.items():
481
+ bpe = BrokenProcessPool("A process in the process pool was "
482
+ "terminated abruptly while the future was "
483
+ "running or pending.")
484
+ if cause_tb is not None:
485
+ bpe.__cause__ = _RemoteTraceback(cause_tb)
486
+ try:
487
+ work_item.future.set_exception(bpe)
488
+ except _base.InvalidStateError:
489
+ # set_exception() fails if the future is cancelled: ignore it.
490
+ # Trying to check if the future is cancelled before calling
491
+ # set_exception() would leave a race condition if the future is
492
+ # cancelled between the check and set_exception().
493
+ pass
494
+ # Delete references to object. See issue16284
495
+ del work_item
496
+ self.pending_work_items.clear()
497
+
498
+ # Terminate remaining workers forcibly: the queues or their
499
+ # locks may be in a dirty state and block forever.
500
+ for p in self.processes.values():
501
+ p.terminate()
502
+
503
+ self.call_queue._terminate_broken()
504
+
505
+ # clean up resources
506
+ self._join_executor_internals(broken=True)
507
+
508
+ def terminate_broken(self, cause):
509
+ with self.shutdown_lock:
510
+ self._terminate_broken(cause)
511
+
512
+ def flag_executor_shutting_down(self):
513
+ # Flag the executor as shutting down and cancel remaining tasks if
514
+ # requested as early as possible if it is not gc-ed yet.
515
+ executor = self.executor_reference()
516
+ if executor is not None:
517
+ executor._shutdown_thread = True
518
+ # Cancel pending work items if requested.
519
+ if executor._cancel_pending_futures:
520
+ # Cancel all pending futures and update pending_work_items
521
+ # to only have futures that are currently running.
522
+ new_pending_work_items = {}
523
+ for work_id, work_item in self.pending_work_items.items():
524
+ if not work_item.future.cancel():
525
+ new_pending_work_items[work_id] = work_item
526
+ self.pending_work_items = new_pending_work_items
527
+ # Drain work_ids_queue since we no longer need to
528
+ # add items to the call queue.
529
+ while True:
530
+ try:
531
+ self.work_ids_queue.get_nowait()
532
+ except queue.Empty:
533
+ break
534
+ # Make sure we do this only once to not waste time looping
535
+ # on running processes over and over.
536
+ executor._cancel_pending_futures = False
537
+
538
+ def shutdown_workers(self):
539
+ n_children_to_stop = self.get_n_children_alive()
540
+ n_sentinels_sent = 0
541
+ # Send the right number of sentinels, to make sure all children are
542
+ # properly terminated.
543
+ while (n_sentinels_sent < n_children_to_stop
544
+ and self.get_n_children_alive() > 0):
545
+ for i in range(n_children_to_stop - n_sentinels_sent):
546
+ try:
547
+ self.call_queue.put_nowait(None)
548
+ n_sentinels_sent += 1
549
+ except queue.Full:
550
+ break
551
+
552
+ def join_executor_internals(self):
553
+ with self.shutdown_lock:
554
+ self._join_executor_internals()
555
+
556
+ def _join_executor_internals(self, broken=False):
557
+ # If broken, call_queue was closed and so can no longer be used.
558
+ if not broken:
559
+ self.shutdown_workers()
560
+
561
+ # Release the queue's resources as soon as possible.
562
+ self.call_queue.close()
563
+ self.call_queue.join_thread()
564
+ self.thread_wakeup.close()
565
+
566
+ # If .join() is not called on the created processes then
567
+ # some ctx.Queue methods may deadlock on Mac OS X.
568
+ for p in self.processes.values():
569
+ if broken:
570
+ p.terminate()
571
+ p.join()
572
+
573
+ def get_n_children_alive(self):
574
+ # This is an upper bound on the number of children alive.
575
+ return sum(p.is_alive() for p in self.processes.values())
576
+
577
+
578
+ _system_limits_checked = False
579
+ _system_limited = None
580
+
581
+
582
+ def _check_system_limits():
583
+ global _system_limits_checked, _system_limited
584
+ if _system_limits_checked:
585
+ if _system_limited:
586
+ raise NotImplementedError(_system_limited)
587
+ _system_limits_checked = True
588
+ try:
589
+ import multiprocessing.synchronize
590
+ except ImportError:
591
+ _system_limited = (
592
+ "This Python build lacks multiprocessing.synchronize, usually due "
593
+ "to named semaphores being unavailable on this platform."
594
+ )
595
+ raise NotImplementedError(_system_limited)
596
+ try:
597
+ nsems_max = os.sysconf("SC_SEM_NSEMS_MAX")
598
+ except (AttributeError, ValueError):
599
+ # sysconf not available or setting not available
600
+ return
601
+ if nsems_max == -1:
602
+ # indetermined limit, assume that limit is determined
603
+ # by available memory only
604
+ return
605
+ if nsems_max >= 256:
606
+ # minimum number of semaphores available
607
+ # according to POSIX
608
+ return
609
+ _system_limited = ("system provides too few semaphores (%d"
610
+ " available, 256 necessary)" % nsems_max)
611
+ raise NotImplementedError(_system_limited)
612
+
613
+
614
+ def _chain_from_iterable_of_lists(iterable):
615
+ """
616
+ Specialized implementation of itertools.chain.from_iterable.
617
+ Each item in *iterable* should be a list. This function is
618
+ careful not to keep references to yielded objects.
619
+ """
620
+ for element in iterable:
621
+ element.reverse()
622
+ while element:
623
+ yield element.pop()
624
+
625
+
626
+ class BrokenProcessPool(_base.BrokenExecutor):
627
+ """
628
+ Raised when a process in a ProcessPoolExecutor terminated abruptly
629
+ while a future was in the running state.
630
+ """
631
+
632
+
633
+ class ProcessPoolExecutor(_base.Executor):
634
+ def __init__(self, max_workers=None, mp_context=None,
635
+ initializer=None, initargs=(), *, max_tasks_per_child=None):
636
+ """Initializes a new ProcessPoolExecutor instance.
637
+
638
+ Args:
639
+ max_workers: The maximum number of processes that can be used to
640
+ execute the given calls. If None or not given then as many
641
+ worker processes will be created as the machine has
642
+ processors.
643
+ mp_context: A multiprocessing context to launch the workers
644
+ created using the multiprocessing.get_context('start method')
645
+ API. This object should provide SimpleQueue, Queue and
646
+ Process.
647
+ initializer: A callable used to initialize worker processes.
648
+ initargs: A tuple of arguments to pass to the initializer.
649
+ max_tasks_per_child: The maximum number of tasks a worker
650
+ process can complete before it will exit and be replaced
651
+ with a fresh worker process. The default of None means
652
+ worker process will live as long as the executor. Requires
653
+ a non-'fork' mp_context start method. When given, we
654
+ default to using 'spawn' if no mp_context is supplied.
655
+ """
656
+ _check_system_limits()
657
+
658
+ if max_workers is None:
659
+ self._max_workers = os.process_cpu_count() or 1
660
+ if sys.platform == 'win32':
661
+ self._max_workers = min(_MAX_WINDOWS_WORKERS,
662
+ self._max_workers)
663
+ else:
664
+ if max_workers <= 0:
665
+ raise ValueError("max_workers must be greater than 0")
666
+ elif (sys.platform == 'win32' and
667
+ max_workers > _MAX_WINDOWS_WORKERS):
668
+ raise ValueError(
669
+ f"max_workers must be <= {_MAX_WINDOWS_WORKERS}")
670
+
671
+ self._max_workers = max_workers
672
+
673
+ if mp_context is None:
674
+ if max_tasks_per_child is not None:
675
+ mp_context = mp.get_context("spawn")
676
+ else:
677
+ mp_context = mp.get_context()
678
+ self._mp_context = mp_context
679
+
680
+ # https://github.com/python/cpython/issues/90622
681
+ self._safe_to_dynamically_spawn_children = (
682
+ self._mp_context.get_start_method(allow_none=False) != "fork")
683
+
684
+ if initializer is not None and not callable(initializer):
685
+ raise TypeError("initializer must be a callable")
686
+ self._initializer = initializer
687
+ self._initargs = initargs
688
+
689
+ if max_tasks_per_child is not None:
690
+ if not isinstance(max_tasks_per_child, int):
691
+ raise TypeError("max_tasks_per_child must be an integer")
692
+ elif max_tasks_per_child <= 0:
693
+ raise ValueError("max_tasks_per_child must be >= 1")
694
+ if self._mp_context.get_start_method(allow_none=False) == "fork":
695
+ # https://github.com/python/cpython/issues/90622
696
+ raise ValueError("max_tasks_per_child is incompatible with"
697
+ " the 'fork' multiprocessing start method;"
698
+ " supply a different mp_context.")
699
+ self._max_tasks_per_child = max_tasks_per_child
700
+
701
+ # Management thread
702
+ self._executor_manager_thread = None
703
+
704
+ # Map of pids to processes
705
+ self._processes = {}
706
+
707
+ # Shutdown is a two-step process.
708
+ self._shutdown_thread = False
709
+ self._shutdown_lock = threading.Lock()
710
+ self._idle_worker_semaphore = threading.Semaphore(0)
711
+ self._broken = False
712
+ self._queue_count = 0
713
+ self._pending_work_items = {}
714
+ self._cancel_pending_futures = False
715
+
716
+ # _ThreadWakeup is a communication channel used to interrupt the wait
717
+ # of the main loop of executor_manager_thread from another thread (e.g.
718
+ # when calling executor.submit or executor.shutdown). We do not use the
719
+ # _result_queue to send wakeup signals to the executor_manager_thread
720
+ # as it could result in a deadlock if a worker process dies with the
721
+ # _result_queue write lock still acquired.
722
+ #
723
+ # Care must be taken to only call clear and close from the
724
+ # executor_manager_thread, since _ThreadWakeup.clear() is not protected
725
+ # by a lock.
726
+ self._executor_manager_thread_wakeup = _ThreadWakeup()
727
+
728
+ # Create communication channels for the executor
729
+ # Make the call queue slightly larger than the number of processes to
730
+ # prevent the worker processes from idling. But don't make it too big
731
+ # because futures in the call queue cannot be cancelled.
732
+ queue_size = self._max_workers + EXTRA_QUEUED_CALLS
733
+ self._call_queue = _SafeQueue(
734
+ max_size=queue_size, ctx=self._mp_context,
735
+ pending_work_items=self._pending_work_items,
736
+ thread_wakeup=self._executor_manager_thread_wakeup)
737
+ # Killed worker processes can produce spurious "broken pipe"
738
+ # tracebacks in the queue's own worker thread. But we detect killed
739
+ # processes anyway, so silence the tracebacks.
740
+ self._call_queue._ignore_epipe = True
741
+ self._result_queue = mp_context.SimpleQueue()
742
+ self._work_ids = queue.Queue()
743
+
744
+ def _start_executor_manager_thread(self):
745
+ if self._executor_manager_thread is None:
746
+ # Start the processes so that their sentinels are known.
747
+ if not self._safe_to_dynamically_spawn_children: # ie, using fork.
748
+ self._launch_processes()
749
+ self._executor_manager_thread = _ExecutorManagerThread(self)
750
+ self._executor_manager_thread.start()
751
+ _threads_wakeups[self._executor_manager_thread] = \
752
+ self._executor_manager_thread_wakeup
753
+
754
+ def _replace_dead_worker(self):
755
+ # gh-132969: avoid error when state is reset and executor is still running,
756
+ # which will happen when shutdown(wait=False) is called.
757
+ if self._processes is None:
758
+ return
759
+
760
+ # A replacement is pointless when shutting down with nothing left
761
+ # to run. Both attributes are read under _shutdown_lock, which
762
+ # shutdown() holds while setting _shutdown_thread.
763
+ assert self._shutdown_lock.locked()
764
+ if self._shutdown_thread and not self._pending_work_items:
765
+ return
766
+
767
+ # gh-115634: A worker exited after reaching max_tasks_per_child and
768
+ # has been removed from self._processes. Do not consult
769
+ # _idle_worker_semaphore here: it counts task completions, not idle
770
+ # workers, so it can hold a stale token released by the now-dead
771
+ # worker. Trusting such a token would leave the pool a worker short,
772
+ # deadlocking once all workers reach their task limit. Spawning is
773
+ # safe from this (manager) thread despite gh-90622 because
774
+ # max_tasks_per_child is rejected for the "fork" start method.
775
+ if len(self._processes) < self._max_workers:
776
+ self._spawn_process()
777
+
778
+ def _adjust_process_count(self):
779
+ # gh-132969: avoid error when state is reset and executor is still running,
780
+ # which will happen when shutdown(wait=False) is called.
781
+ if self._processes is None:
782
+ return
783
+
784
+ # if there's an idle process, we don't need to spawn a new one.
785
+ if self._idle_worker_semaphore.acquire(blocking=False):
786
+ return
787
+
788
+ process_count = len(self._processes)
789
+ if process_count < self._max_workers:
790
+ # gh-90622: spawning a child via fork while another thread is
791
+ # running can deadlock in the child. submit() only calls this
792
+ # method when using a non-fork start method.
793
+ assert (self._safe_to_dynamically_spawn_children
794
+ or not self._executor_manager_thread), (
795
+ 'https://github.com/python/cpython/issues/90622')
796
+ self._spawn_process()
797
+
798
+ def _launch_processes(self):
799
+ # https://github.com/python/cpython/issues/90622
800
+ assert not self._executor_manager_thread, (
801
+ 'Processes cannot be fork()ed after the thread has started, '
802
+ 'deadlock in the child processes could result.')
803
+ for _ in range(len(self._processes), self._max_workers):
804
+ self._spawn_process()
805
+
806
+ def _spawn_process(self):
807
+ p = self._mp_context.Process(
808
+ target=_process_worker,
809
+ args=(self._call_queue,
810
+ self._result_queue,
811
+ self._initializer,
812
+ self._initargs,
813
+ self._max_tasks_per_child))
814
+ p.start()
815
+ self._processes[p.pid] = p
816
+
817
+ def submit(self, fn, /, *args, **kwargs):
818
+ with self._shutdown_lock:
819
+ if self._broken:
820
+ raise BrokenProcessPool(self._broken)
821
+ if self._shutdown_thread:
822
+ raise RuntimeError('cannot schedule new futures after shutdown')
823
+ if _global_shutdown:
824
+ raise RuntimeError('cannot schedule new futures after '
825
+ 'interpreter shutdown')
826
+
827
+ f = _base.Future()
828
+ w = _WorkItem(f, fn, args, kwargs)
829
+
830
+ self._pending_work_items[self._queue_count] = w
831
+ self._work_ids.put(self._queue_count)
832
+ self._queue_count += 1
833
+ # Wake up queue management thread
834
+ self._executor_manager_thread_wakeup.wakeup()
835
+
836
+ if self._safe_to_dynamically_spawn_children:
837
+ self._adjust_process_count()
838
+ self._start_executor_manager_thread()
839
+ return f
840
+ submit.__doc__ = _base.Executor.submit.__doc__
841
+
842
+ def map(self, fn, *iterables, timeout=None, chunksize=1):
843
+ """Returns an iterator equivalent to map(fn, iter).
844
+
845
+ Args:
846
+ fn: A callable that will take as many arguments as there are
847
+ passed iterables.
848
+ timeout: The maximum number of seconds to wait. If None, then
849
+ there is no limit on the wait time.
850
+ chunksize: If greater than one, the iterables will be chopped
851
+ into chunks of size chunksize and submitted to the process
852
+ pool. If set to one, the items in the list will be sent
853
+ one at a time.
854
+
855
+ Returns:
856
+ An iterator equivalent to: map(func, *iterables) but the calls
857
+ may be evaluated out-of-order.
858
+
859
+ Raises:
860
+ TimeoutError: If the entire result iterator could not be
861
+ generated before the given timeout.
862
+ Exception: If fn(*args) raises for any values.
863
+ """
864
+ if chunksize < 1:
865
+ raise ValueError("chunksize must be >= 1.")
866
+
867
+ results = super().map(partial(_process_chunk, fn),
868
+ itertools.batched(zip(*iterables), chunksize),
869
+ timeout=timeout)
870
+ return _chain_from_iterable_of_lists(results)
871
+
872
+ def shutdown(self, wait=True, *, cancel_futures=False):
873
+ with self._shutdown_lock:
874
+ self._cancel_pending_futures = cancel_futures
875
+ self._shutdown_thread = True
876
+ if self._executor_manager_thread_wakeup is not None:
877
+ # Wake up queue management thread
878
+ self._executor_manager_thread_wakeup.wakeup()
879
+
880
+ if self._executor_manager_thread is not None and wait:
881
+ self._executor_manager_thread.join()
882
+ # To reduce the risk of opening too many files, remove references to
883
+ # objects that use file descriptors.
884
+ self._executor_manager_thread = None
885
+ self._call_queue = None
886
+ if self._result_queue is not None and wait:
887
+ self._result_queue.close()
888
+ self._result_queue = None
889
+ self._processes = None
890
+ self._executor_manager_thread_wakeup = None
891
+
892
+ shutdown.__doc__ = _base.Executor.shutdown.__doc__