@tedbrain/vlink 0.0.0-dpv2.ted-runner.plugin.0.1.1.r6 → 0.0.0-dpv2.ted-runner.python-linux-x64.3.9.0-dpv2.1.r6

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 (710) hide show
  1. package/bin/python3 +0 -0
  2. package/lib/libX11.so.6 +0 -0
  3. package/lib/libXau.so.6 +0 -0
  4. package/lib/libXdmcp.so.6 +0 -0
  5. package/lib/libcrypt.so.1 +0 -0
  6. package/lib/libcrypto.so.1.1 +0 -0
  7. package/lib/libffi.so.7 +0 -0
  8. package/lib/libfreebl3.so +0 -0
  9. package/lib/liblzma.so.5 +0 -0
  10. package/lib/libncursesw.so.6 +0 -0
  11. package/lib/libnsl.so.1 +0 -0
  12. package/lib/libpanelw.so.6 +0 -0
  13. package/lib/libpython3.9.so.1.0 +0 -0
  14. package/lib/libreadline.so.8 +0 -0
  15. package/lib/libsqlite3.so.0 +0 -0
  16. package/lib/libssl.so.1.1 +0 -0
  17. package/lib/libtcl8.6.so +0 -0
  18. package/lib/libtinfow.so.6 +0 -0
  19. package/lib/libtk8.6.so +0 -0
  20. package/lib/libxcb.so.1 +0 -0
  21. package/lib/libz.so.1 +0 -0
  22. package/lib/python3.9/LICENSE.txt +279 -0
  23. package/lib/python3.9/__future__.py +147 -0
  24. package/lib/python3.9/__phello__.foo.py +1 -0
  25. package/lib/python3.9/_aix_support.py +89 -0
  26. package/lib/python3.9/_bootlocale.py +46 -0
  27. package/lib/python3.9/_bootsubprocess.py +97 -0
  28. package/lib/python3.9/_collections_abc.py +1031 -0
  29. package/lib/python3.9/_compat_pickle.py +251 -0
  30. package/lib/python3.9/_compression.py +152 -0
  31. package/lib/python3.9/_markupbase.py +395 -0
  32. package/lib/python3.9/_osx_support.py +515 -0
  33. package/lib/python3.9/_py_abc.py +147 -0
  34. package/lib/python3.9/_pydecimal.py +6410 -0
  35. package/lib/python3.9/_pyio.py +2692 -0
  36. package/lib/python3.9/_sitebuiltins.py +103 -0
  37. package/lib/python3.9/_strptime.py +579 -0
  38. package/lib/python3.9/_sysconfigdata__linux_x86_64-linux-gnu.py +969 -0
  39. package/lib/python3.9/_sysconfigdata__linux_x86_64-linux-gnu.py.orig +969 -0
  40. package/lib/python3.9/_sysconfigdata_x86_64_conda_cos6_linux_gnu.py +969 -0
  41. package/lib/python3.9/_threading_local.py +242 -0
  42. package/lib/python3.9/_weakrefset.py +202 -0
  43. package/lib/python3.9/abc.py +129 -0
  44. package/lib/python3.9/aifc.py +947 -0
  45. package/lib/python3.9/antigravity.py +17 -0
  46. package/lib/python3.9/argparse.py +2575 -0
  47. package/lib/python3.9/ast.py +1530 -0
  48. package/lib/python3.9/asynchat.py +307 -0
  49. package/lib/python3.9/asyncio/__init__.py +47 -0
  50. package/lib/python3.9/asyncio/__main__.py +125 -0
  51. package/lib/python3.9/asyncio/base_events.py +1915 -0
  52. package/lib/python3.9/asyncio/base_futures.py +61 -0
  53. package/lib/python3.9/asyncio/base_subprocess.py +285 -0
  54. package/lib/python3.9/asyncio/base_tasks.py +85 -0
  55. package/lib/python3.9/asyncio/constants.py +27 -0
  56. package/lib/python3.9/asyncio/coroutines.py +269 -0
  57. package/lib/python3.9/asyncio/events.py +795 -0
  58. package/lib/python3.9/asyncio/exceptions.py +57 -0
  59. package/lib/python3.9/asyncio/format_helpers.py +76 -0
  60. package/lib/python3.9/asyncio/futures.py +423 -0
  61. package/lib/python3.9/asyncio/locks.py +451 -0
  62. package/lib/python3.9/asyncio/log.py +7 -0
  63. package/lib/python3.9/asyncio/proactor_events.py +868 -0
  64. package/lib/python3.9/asyncio/protocols.py +220 -0
  65. package/lib/python3.9/asyncio/queues.py +252 -0
  66. package/lib/python3.9/asyncio/runners.py +74 -0
  67. package/lib/python3.9/asyncio/selector_events.py +1099 -0
  68. package/lib/python3.9/asyncio/sslproto.py +733 -0
  69. package/lib/python3.9/asyncio/staggered.py +149 -0
  70. package/lib/python3.9/asyncio/streams.py +741 -0
  71. package/lib/python3.9/asyncio/subprocess.py +241 -0
  72. package/lib/python3.9/asyncio/tasks.py +980 -0
  73. package/lib/python3.9/asyncio/threads.py +25 -0
  74. package/lib/python3.9/asyncio/transports.py +329 -0
  75. package/lib/python3.9/asyncio/trsock.py +206 -0
  76. package/lib/python3.9/asyncio/unix_events.py +1466 -0
  77. package/lib/python3.9/asyncio/windows_events.py +908 -0
  78. package/lib/python3.9/asyncio/windows_utils.py +173 -0
  79. package/lib/python3.9/asyncore.py +642 -0
  80. package/lib/python3.9/base64.py +579 -0
  81. package/lib/python3.9/bdb.py +864 -0
  82. package/lib/python3.9/binhex.py +502 -0
  83. package/lib/python3.9/bisect.py +80 -0
  84. package/lib/python3.9/bz2.py +350 -0
  85. package/lib/python3.9/cProfile.py +180 -0
  86. package/lib/python3.9/calendar.py +770 -0
  87. package/lib/python3.9/cgi.py +996 -0
  88. package/lib/python3.9/cgitb.py +321 -0
  89. package/lib/python3.9/chunk.py +169 -0
  90. package/lib/python3.9/cmd.py +401 -0
  91. package/lib/python3.9/code.py +315 -0
  92. package/lib/python3.9/codecs.py +1126 -0
  93. package/lib/python3.9/codeop.py +178 -0
  94. package/lib/python3.9/collections/__init__.py +1508 -0
  95. package/lib/python3.9/collections/abc.py +2 -0
  96. package/lib/python3.9/colorsys.py +164 -0
  97. package/lib/python3.9/compileall.py +461 -0
  98. package/lib/python3.9/concurrent/__init__.py +1 -0
  99. package/lib/python3.9/concurrent/futures/__init__.py +53 -0
  100. package/lib/python3.9/concurrent/futures/_base.py +635 -0
  101. package/lib/python3.9/concurrent/futures/process.py +751 -0
  102. package/lib/python3.9/concurrent/futures/thread.py +230 -0
  103. package/lib/python3.9/config-3.9-x86_64-linux-gnu/Makefile +2015 -0
  104. package/lib/python3.9/config-3.9-x86_64-linux-gnu/Setup +372 -0
  105. package/lib/python3.9/config-3.9-x86_64-linux-gnu/Setup.local +1 -0
  106. package/lib/python3.9/config-3.9-x86_64-linux-gnu/config.c +116 -0
  107. package/lib/python3.9/config-3.9-x86_64-linux-gnu/config.c.in +67 -0
  108. package/lib/python3.9/config-3.9-x86_64-linux-gnu/install-sh +518 -0
  109. package/lib/python3.9/config-3.9-x86_64-linux-gnu/makesetup +309 -0
  110. package/lib/python3.9/config-3.9-x86_64-linux-gnu/python-config.py +74 -0
  111. package/lib/python3.9/config-3.9-x86_64-linux-gnu/python.o +0 -0
  112. package/lib/python3.9/configparser.py +1363 -0
  113. package/lib/python3.9/contextlib.py +676 -0
  114. package/lib/python3.9/contextvars.py +4 -0
  115. package/lib/python3.9/copy.py +303 -0
  116. package/lib/python3.9/copyreg.py +209 -0
  117. package/lib/python3.9/crypt.py +120 -0
  118. package/lib/python3.9/csv.py +448 -0
  119. package/lib/python3.9/ctypes/__init__.py +571 -0
  120. package/lib/python3.9/ctypes/_aix.py +331 -0
  121. package/lib/python3.9/ctypes/_endian.py +61 -0
  122. package/lib/python3.9/ctypes/macholib/README.ctypes +7 -0
  123. package/lib/python3.9/ctypes/macholib/__init__.py +9 -0
  124. package/lib/python3.9/ctypes/macholib/dyld.py +182 -0
  125. package/lib/python3.9/ctypes/macholib/dylib.py +63 -0
  126. package/lib/python3.9/ctypes/macholib/fetch_macholib +2 -0
  127. package/lib/python3.9/ctypes/macholib/fetch_macholib.bat +1 -0
  128. package/lib/python3.9/ctypes/macholib/framework.py +65 -0
  129. package/lib/python3.9/ctypes/util.py +379 -0
  130. package/lib/python3.9/ctypes/wintypes.py +202 -0
  131. package/lib/python3.9/curses/__init__.py +101 -0
  132. package/lib/python3.9/curses/ascii.py +99 -0
  133. package/lib/python3.9/curses/has_key.py +192 -0
  134. package/lib/python3.9/curses/panel.py +6 -0
  135. package/lib/python3.9/curses/textpad.py +201 -0
  136. package/lib/python3.9/dataclasses.py +1284 -0
  137. package/lib/python3.9/datetime.py +2555 -0
  138. package/lib/python3.9/dbm/__init__.py +189 -0
  139. package/lib/python3.9/dbm/dumb.py +316 -0
  140. package/lib/python3.9/dbm/gnu.py +3 -0
  141. package/lib/python3.9/dbm/ndbm.py +3 -0
  142. package/lib/python3.9/decimal.py +11 -0
  143. package/lib/python3.9/difflib.py +2096 -0
  144. package/lib/python3.9/dis.py +553 -0
  145. package/lib/python3.9/distutils/README +11 -0
  146. package/lib/python3.9/distutils/__init__.py +13 -0
  147. package/lib/python3.9/distutils/_msvccompiler.py +546 -0
  148. package/lib/python3.9/distutils/archive_util.py +256 -0
  149. package/lib/python3.9/distutils/bcppcompiler.py +393 -0
  150. package/lib/python3.9/distutils/ccompiler.py +1116 -0
  151. package/lib/python3.9/distutils/cmd.py +403 -0
  152. package/lib/python3.9/distutils/command/__init__.py +31 -0
  153. package/lib/python3.9/distutils/command/bdist.py +143 -0
  154. package/lib/python3.9/distutils/command/bdist_dumb.py +123 -0
  155. package/lib/python3.9/distutils/command/bdist_msi.py +749 -0
  156. package/lib/python3.9/distutils/command/bdist_rpm.py +579 -0
  157. package/lib/python3.9/distutils/command/bdist_wininst.py +377 -0
  158. package/lib/python3.9/distutils/command/build.py +157 -0
  159. package/lib/python3.9/distutils/command/build_clib.py +209 -0
  160. package/lib/python3.9/distutils/command/build_ext.py +754 -0
  161. package/lib/python3.9/distutils/command/build_py.py +416 -0
  162. package/lib/python3.9/distutils/command/build_scripts.py +160 -0
  163. package/lib/python3.9/distutils/command/check.py +148 -0
  164. package/lib/python3.9/distutils/command/clean.py +76 -0
  165. package/lib/python3.9/distutils/command/command_template +33 -0
  166. package/lib/python3.9/distutils/command/config.py +344 -0
  167. package/lib/python3.9/distutils/command/install.py +657 -0
  168. package/lib/python3.9/distutils/command/install_data.py +79 -0
  169. package/lib/python3.9/distutils/command/install_egg_info.py +77 -0
  170. package/lib/python3.9/distutils/command/install_headers.py +47 -0
  171. package/lib/python3.9/distutils/command/install_lib.py +217 -0
  172. package/lib/python3.9/distutils/command/install_scripts.py +60 -0
  173. package/lib/python3.9/distutils/command/register.py +304 -0
  174. package/lib/python3.9/distutils/command/sdist.py +494 -0
  175. package/lib/python3.9/distutils/command/upload.py +214 -0
  176. package/lib/python3.9/distutils/config.py +130 -0
  177. package/lib/python3.9/distutils/core.py +234 -0
  178. package/lib/python3.9/distutils/cygwinccompiler.py +410 -0
  179. package/lib/python3.9/distutils/debug.py +5 -0
  180. package/lib/python3.9/distutils/dep_util.py +92 -0
  181. package/lib/python3.9/distutils/dir_util.py +210 -0
  182. package/lib/python3.9/distutils/dist.py +1256 -0
  183. package/lib/python3.9/distutils/errors.py +97 -0
  184. package/lib/python3.9/distutils/extension.py +240 -0
  185. package/lib/python3.9/distutils/fancy_getopt.py +457 -0
  186. package/lib/python3.9/distutils/file_util.py +238 -0
  187. package/lib/python3.9/distutils/filelist.py +327 -0
  188. package/lib/python3.9/distutils/log.py +77 -0
  189. package/lib/python3.9/distutils/msvc9compiler.py +788 -0
  190. package/lib/python3.9/distutils/msvccompiler.py +643 -0
  191. package/lib/python3.9/distutils/spawn.py +125 -0
  192. package/lib/python3.9/distutils/sysconfig.py +560 -0
  193. package/lib/python3.9/distutils/text_file.py +286 -0
  194. package/lib/python3.9/distutils/unixccompiler.py +330 -0
  195. package/lib/python3.9/distutils/util.py +559 -0
  196. package/lib/python3.9/distutils/version.py +347 -0
  197. package/lib/python3.9/distutils/versionpredicate.py +166 -0
  198. package/lib/python3.9/doctest.py +2793 -0
  199. package/lib/python3.9/email/__init__.py +62 -0
  200. package/lib/python3.9/email/_encoded_words.py +233 -0
  201. package/lib/python3.9/email/_header_value_parser.py +3003 -0
  202. package/lib/python3.9/email/_parseaddr.py +549 -0
  203. package/lib/python3.9/email/_policybase.py +374 -0
  204. package/lib/python3.9/email/architecture.rst +216 -0
  205. package/lib/python3.9/email/base64mime.py +119 -0
  206. package/lib/python3.9/email/charset.py +404 -0
  207. package/lib/python3.9/email/contentmanager.py +250 -0
  208. package/lib/python3.9/email/encoders.py +69 -0
  209. package/lib/python3.9/email/errors.py +110 -0
  210. package/lib/python3.9/email/feedparser.py +536 -0
  211. package/lib/python3.9/email/generator.py +508 -0
  212. package/lib/python3.9/email/header.py +578 -0
  213. package/lib/python3.9/email/headerregistry.py +601 -0
  214. package/lib/python3.9/email/iterators.py +71 -0
  215. package/lib/python3.9/email/message.py +1173 -0
  216. package/lib/python3.9/email/mime/__init__.py +0 -0
  217. package/lib/python3.9/email/mime/application.py +37 -0
  218. package/lib/python3.9/email/mime/audio.py +74 -0
  219. package/lib/python3.9/email/mime/base.py +30 -0
  220. package/lib/python3.9/email/mime/image.py +47 -0
  221. package/lib/python3.9/email/mime/message.py +34 -0
  222. package/lib/python3.9/email/mime/multipart.py +48 -0
  223. package/lib/python3.9/email/mime/nonmultipart.py +22 -0
  224. package/lib/python3.9/email/mime/text.py +42 -0
  225. package/lib/python3.9/email/parser.py +131 -0
  226. package/lib/python3.9/email/policy.py +224 -0
  227. package/lib/python3.9/email/quoprimime.py +299 -0
  228. package/lib/python3.9/email/utils.py +368 -0
  229. package/lib/python3.9/encodings/__init__.py +169 -0
  230. package/lib/python3.9/encodings/aliases.py +551 -0
  231. package/lib/python3.9/encodings/ascii.py +50 -0
  232. package/lib/python3.9/encodings/base64_codec.py +55 -0
  233. package/lib/python3.9/encodings/big5.py +39 -0
  234. package/lib/python3.9/encodings/big5hkscs.py +39 -0
  235. package/lib/python3.9/encodings/bz2_codec.py +78 -0
  236. package/lib/python3.9/encodings/charmap.py +69 -0
  237. package/lib/python3.9/encodings/cp037.py +307 -0
  238. package/lib/python3.9/encodings/cp1006.py +307 -0
  239. package/lib/python3.9/encodings/cp1026.py +307 -0
  240. package/lib/python3.9/encodings/cp1125.py +698 -0
  241. package/lib/python3.9/encodings/cp1140.py +307 -0
  242. package/lib/python3.9/encodings/cp1250.py +307 -0
  243. package/lib/python3.9/encodings/cp1251.py +307 -0
  244. package/lib/python3.9/encodings/cp1252.py +307 -0
  245. package/lib/python3.9/encodings/cp1253.py +307 -0
  246. package/lib/python3.9/encodings/cp1254.py +307 -0
  247. package/lib/python3.9/encodings/cp1255.py +307 -0
  248. package/lib/python3.9/encodings/cp1256.py +307 -0
  249. package/lib/python3.9/encodings/cp1257.py +307 -0
  250. package/lib/python3.9/encodings/cp1258.py +307 -0
  251. package/lib/python3.9/encodings/cp273.py +307 -0
  252. package/lib/python3.9/encodings/cp424.py +307 -0
  253. package/lib/python3.9/encodings/cp437.py +698 -0
  254. package/lib/python3.9/encodings/cp500.py +307 -0
  255. package/lib/python3.9/encodings/cp720.py +309 -0
  256. package/lib/python3.9/encodings/cp737.py +698 -0
  257. package/lib/python3.9/encodings/cp775.py +697 -0
  258. package/lib/python3.9/encodings/cp850.py +698 -0
  259. package/lib/python3.9/encodings/cp852.py +698 -0
  260. package/lib/python3.9/encodings/cp855.py +698 -0
  261. package/lib/python3.9/encodings/cp856.py +307 -0
  262. package/lib/python3.9/encodings/cp857.py +694 -0
  263. package/lib/python3.9/encodings/cp858.py +698 -0
  264. package/lib/python3.9/encodings/cp860.py +698 -0
  265. package/lib/python3.9/encodings/cp861.py +698 -0
  266. package/lib/python3.9/encodings/cp862.py +698 -0
  267. package/lib/python3.9/encodings/cp863.py +698 -0
  268. package/lib/python3.9/encodings/cp864.py +690 -0
  269. package/lib/python3.9/encodings/cp865.py +698 -0
  270. package/lib/python3.9/encodings/cp866.py +698 -0
  271. package/lib/python3.9/encodings/cp869.py +689 -0
  272. package/lib/python3.9/encodings/cp874.py +307 -0
  273. package/lib/python3.9/encodings/cp875.py +307 -0
  274. package/lib/python3.9/encodings/cp932.py +39 -0
  275. package/lib/python3.9/encodings/cp949.py +39 -0
  276. package/lib/python3.9/encodings/cp950.py +39 -0
  277. package/lib/python3.9/encodings/euc_jis_2004.py +39 -0
  278. package/lib/python3.9/encodings/euc_jisx0213.py +39 -0
  279. package/lib/python3.9/encodings/euc_jp.py +39 -0
  280. package/lib/python3.9/encodings/euc_kr.py +39 -0
  281. package/lib/python3.9/encodings/gb18030.py +39 -0
  282. package/lib/python3.9/encodings/gb2312.py +39 -0
  283. package/lib/python3.9/encodings/gbk.py +39 -0
  284. package/lib/python3.9/encodings/hex_codec.py +55 -0
  285. package/lib/python3.9/encodings/hp_roman8.py +314 -0
  286. package/lib/python3.9/encodings/hz.py +39 -0
  287. package/lib/python3.9/encodings/idna.py +309 -0
  288. package/lib/python3.9/encodings/iso2022_jp.py +39 -0
  289. package/lib/python3.9/encodings/iso2022_jp_1.py +39 -0
  290. package/lib/python3.9/encodings/iso2022_jp_2.py +39 -0
  291. package/lib/python3.9/encodings/iso2022_jp_2004.py +39 -0
  292. package/lib/python3.9/encodings/iso2022_jp_3.py +39 -0
  293. package/lib/python3.9/encodings/iso2022_jp_ext.py +39 -0
  294. package/lib/python3.9/encodings/iso2022_kr.py +39 -0
  295. package/lib/python3.9/encodings/iso8859_1.py +307 -0
  296. package/lib/python3.9/encodings/iso8859_10.py +307 -0
  297. package/lib/python3.9/encodings/iso8859_11.py +307 -0
  298. package/lib/python3.9/encodings/iso8859_13.py +307 -0
  299. package/lib/python3.9/encodings/iso8859_14.py +307 -0
  300. package/lib/python3.9/encodings/iso8859_15.py +307 -0
  301. package/lib/python3.9/encodings/iso8859_16.py +307 -0
  302. package/lib/python3.9/encodings/iso8859_2.py +307 -0
  303. package/lib/python3.9/encodings/iso8859_3.py +307 -0
  304. package/lib/python3.9/encodings/iso8859_4.py +307 -0
  305. package/lib/python3.9/encodings/iso8859_5.py +307 -0
  306. package/lib/python3.9/encodings/iso8859_6.py +307 -0
  307. package/lib/python3.9/encodings/iso8859_7.py +307 -0
  308. package/lib/python3.9/encodings/iso8859_8.py +307 -0
  309. package/lib/python3.9/encodings/iso8859_9.py +307 -0
  310. package/lib/python3.9/encodings/johab.py +39 -0
  311. package/lib/python3.9/encodings/koi8_r.py +307 -0
  312. package/lib/python3.9/encodings/koi8_t.py +308 -0
  313. package/lib/python3.9/encodings/koi8_u.py +307 -0
  314. package/lib/python3.9/encodings/kz1048.py +307 -0
  315. package/lib/python3.9/encodings/latin_1.py +50 -0
  316. package/lib/python3.9/encodings/mac_arabic.py +698 -0
  317. package/lib/python3.9/encodings/mac_croatian.py +307 -0
  318. package/lib/python3.9/encodings/mac_cyrillic.py +307 -0
  319. package/lib/python3.9/encodings/mac_farsi.py +307 -0
  320. package/lib/python3.9/encodings/mac_greek.py +307 -0
  321. package/lib/python3.9/encodings/mac_iceland.py +307 -0
  322. package/lib/python3.9/encodings/mac_latin2.py +312 -0
  323. package/lib/python3.9/encodings/mac_roman.py +307 -0
  324. package/lib/python3.9/encodings/mac_romanian.py +307 -0
  325. package/lib/python3.9/encodings/mac_turkish.py +307 -0
  326. package/lib/python3.9/encodings/mbcs.py +47 -0
  327. package/lib/python3.9/encodings/oem.py +41 -0
  328. package/lib/python3.9/encodings/palmos.py +308 -0
  329. package/lib/python3.9/encodings/ptcp154.py +312 -0
  330. package/lib/python3.9/encodings/punycode.py +237 -0
  331. package/lib/python3.9/encodings/quopri_codec.py +56 -0
  332. package/lib/python3.9/encodings/raw_unicode_escape.py +45 -0
  333. package/lib/python3.9/encodings/rot_13.py +113 -0
  334. package/lib/python3.9/encodings/shift_jis.py +39 -0
  335. package/lib/python3.9/encodings/shift_jis_2004.py +39 -0
  336. package/lib/python3.9/encodings/shift_jisx0213.py +39 -0
  337. package/lib/python3.9/encodings/tis_620.py +307 -0
  338. package/lib/python3.9/encodings/undefined.py +49 -0
  339. package/lib/python3.9/encodings/unicode_escape.py +45 -0
  340. package/lib/python3.9/encodings/utf_16.py +155 -0
  341. package/lib/python3.9/encodings/utf_16_be.py +42 -0
  342. package/lib/python3.9/encodings/utf_16_le.py +42 -0
  343. package/lib/python3.9/encodings/utf_32.py +150 -0
  344. package/lib/python3.9/encodings/utf_32_be.py +37 -0
  345. package/lib/python3.9/encodings/utf_32_le.py +37 -0
  346. package/lib/python3.9/encodings/utf_7.py +38 -0
  347. package/lib/python3.9/encodings/utf_8.py +42 -0
  348. package/lib/python3.9/encodings/utf_8_sig.py +130 -0
  349. package/lib/python3.9/encodings/uu_codec.py +103 -0
  350. package/lib/python3.9/encodings/zlib_codec.py +77 -0
  351. package/lib/python3.9/enum.py +913 -0
  352. package/lib/python3.9/filecmp.py +309 -0
  353. package/lib/python3.9/fileinput.py +432 -0
  354. package/lib/python3.9/fnmatch.py +183 -0
  355. package/lib/python3.9/formatter.py +452 -0
  356. package/lib/python3.9/fractions.py +641 -0
  357. package/lib/python3.9/ftplib.py +974 -0
  358. package/lib/python3.9/functools.py +980 -0
  359. package/lib/python3.9/genericpath.py +155 -0
  360. package/lib/python3.9/getopt.py +215 -0
  361. package/lib/python3.9/getpass.py +185 -0
  362. package/lib/python3.9/gettext.py +788 -0
  363. package/lib/python3.9/glob.py +173 -0
  364. package/lib/python3.9/graphlib.py +245 -0
  365. package/lib/python3.9/gzip.py +609 -0
  366. package/lib/python3.9/hashlib.py +262 -0
  367. package/lib/python3.9/heapq.py +601 -0
  368. package/lib/python3.9/hmac.py +203 -0
  369. package/lib/python3.9/html/__init__.py +132 -0
  370. package/lib/python3.9/html/entities.py +2509 -0
  371. package/lib/python3.9/html/parser.py +462 -0
  372. package/lib/python3.9/http/__init__.py +149 -0
  373. package/lib/python3.9/http/client.py +1495 -0
  374. package/lib/python3.9/http/cookiejar.py +2113 -0
  375. package/lib/python3.9/http/cookies.py +612 -0
  376. package/lib/python3.9/http/server.py +1299 -0
  377. package/lib/python3.9/imaplib.py +1650 -0
  378. package/lib/python3.9/imghdr.py +168 -0
  379. package/lib/python3.9/imp.py +345 -0
  380. package/lib/python3.9/importlib/__init__.py +176 -0
  381. package/lib/python3.9/importlib/_bootstrap.py +1189 -0
  382. package/lib/python3.9/importlib/_bootstrap_external.py +1637 -0
  383. package/lib/python3.9/importlib/_common.py +62 -0
  384. package/lib/python3.9/importlib/abc.py +474 -0
  385. package/lib/python3.9/importlib/machinery.py +21 -0
  386. package/lib/python3.9/importlib/metadata.py +586 -0
  387. package/lib/python3.9/importlib/resources.py +215 -0
  388. package/lib/python3.9/importlib/util.py +300 -0
  389. package/lib/python3.9/inspect.py +3180 -0
  390. package/lib/python3.9/io.py +99 -0
  391. package/lib/python3.9/ipaddress.py +2280 -0
  392. package/lib/python3.9/json/__init__.py +359 -0
  393. package/lib/python3.9/json/decoder.py +356 -0
  394. package/lib/python3.9/json/encoder.py +442 -0
  395. package/lib/python3.9/json/scanner.py +73 -0
  396. package/lib/python3.9/json/tool.py +78 -0
  397. package/lib/python3.9/keyword.py +62 -0
  398. package/lib/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so +0 -0
  399. package/lib/python3.9/lib-dynload/_bisect.cpython-39-x86_64-linux-gnu.so +0 -0
  400. package/lib/python3.9/lib-dynload/_blake2.cpython-39-x86_64-linux-gnu.so +0 -0
  401. package/lib/python3.9/lib-dynload/_bz2.cpython-39-x86_64-linux-gnu.so +0 -0
  402. package/lib/python3.9/lib-dynload/_codecs_cn.cpython-39-x86_64-linux-gnu.so +0 -0
  403. package/lib/python3.9/lib-dynload/_codecs_hk.cpython-39-x86_64-linux-gnu.so +0 -0
  404. package/lib/python3.9/lib-dynload/_codecs_iso2022.cpython-39-x86_64-linux-gnu.so +0 -0
  405. package/lib/python3.9/lib-dynload/_codecs_jp.cpython-39-x86_64-linux-gnu.so +0 -0
  406. package/lib/python3.9/lib-dynload/_codecs_kr.cpython-39-x86_64-linux-gnu.so +0 -0
  407. package/lib/python3.9/lib-dynload/_codecs_tw.cpython-39-x86_64-linux-gnu.so +0 -0
  408. package/lib/python3.9/lib-dynload/_contextvars.cpython-39-x86_64-linux-gnu.so +0 -0
  409. package/lib/python3.9/lib-dynload/_crypt.cpython-39-x86_64-linux-gnu.so +0 -0
  410. package/lib/python3.9/lib-dynload/_csv.cpython-39-x86_64-linux-gnu.so +0 -0
  411. package/lib/python3.9/lib-dynload/_ctypes.cpython-39-x86_64-linux-gnu.so +0 -0
  412. package/lib/python3.9/lib-dynload/_ctypes_test.cpython-39-x86_64-linux-gnu.so +0 -0
  413. package/lib/python3.9/lib-dynload/_curses.cpython-39-x86_64-linux-gnu.so +0 -0
  414. package/lib/python3.9/lib-dynload/_curses_panel.cpython-39-x86_64-linux-gnu.so +0 -0
  415. package/lib/python3.9/lib-dynload/_datetime.cpython-39-x86_64-linux-gnu.so +0 -0
  416. package/lib/python3.9/lib-dynload/_decimal.cpython-39-x86_64-linux-gnu.so +0 -0
  417. package/lib/python3.9/lib-dynload/_elementtree.cpython-39-x86_64-linux-gnu.so +0 -0
  418. package/lib/python3.9/lib-dynload/_hashlib.cpython-39-x86_64-linux-gnu.so +0 -0
  419. package/lib/python3.9/lib-dynload/_heapq.cpython-39-x86_64-linux-gnu.so +0 -0
  420. package/lib/python3.9/lib-dynload/_json.cpython-39-x86_64-linux-gnu.so +0 -0
  421. package/lib/python3.9/lib-dynload/_lsprof.cpython-39-x86_64-linux-gnu.so +0 -0
  422. package/lib/python3.9/lib-dynload/_lzma.cpython-39-x86_64-linux-gnu.so +0 -0
  423. package/lib/python3.9/lib-dynload/_md5.cpython-39-x86_64-linux-gnu.so +0 -0
  424. package/lib/python3.9/lib-dynload/_multibytecodec.cpython-39-x86_64-linux-gnu.so +0 -0
  425. package/lib/python3.9/lib-dynload/_multiprocessing.cpython-39-x86_64-linux-gnu.so +0 -0
  426. package/lib/python3.9/lib-dynload/_opcode.cpython-39-x86_64-linux-gnu.so +0 -0
  427. package/lib/python3.9/lib-dynload/_pickle.cpython-39-x86_64-linux-gnu.so +0 -0
  428. package/lib/python3.9/lib-dynload/_posixshmem.cpython-39-x86_64-linux-gnu.so +0 -0
  429. package/lib/python3.9/lib-dynload/_posixsubprocess.cpython-39-x86_64-linux-gnu.so +0 -0
  430. package/lib/python3.9/lib-dynload/_queue.cpython-39-x86_64-linux-gnu.so +0 -0
  431. package/lib/python3.9/lib-dynload/_random.cpython-39-x86_64-linux-gnu.so +0 -0
  432. package/lib/python3.9/lib-dynload/_sha1.cpython-39-x86_64-linux-gnu.so +0 -0
  433. package/lib/python3.9/lib-dynload/_sha256.cpython-39-x86_64-linux-gnu.so +0 -0
  434. package/lib/python3.9/lib-dynload/_sha3.cpython-39-x86_64-linux-gnu.so +0 -0
  435. package/lib/python3.9/lib-dynload/_sha512.cpython-39-x86_64-linux-gnu.so +0 -0
  436. package/lib/python3.9/lib-dynload/_socket.cpython-39-x86_64-linux-gnu.so +0 -0
  437. package/lib/python3.9/lib-dynload/_sqlite3.cpython-39-x86_64-linux-gnu.so +0 -0
  438. package/lib/python3.9/lib-dynload/_ssl.cpython-39-x86_64-linux-gnu.so +0 -0
  439. package/lib/python3.9/lib-dynload/_statistics.cpython-39-x86_64-linux-gnu.so +0 -0
  440. package/lib/python3.9/lib-dynload/_struct.cpython-39-x86_64-linux-gnu.so +0 -0
  441. package/lib/python3.9/lib-dynload/_testbuffer.cpython-39-x86_64-linux-gnu.so +0 -0
  442. package/lib/python3.9/lib-dynload/_testcapi.cpython-39-x86_64-linux-gnu.so +0 -0
  443. package/lib/python3.9/lib-dynload/_testimportmultiple.cpython-39-x86_64-linux-gnu.so +0 -0
  444. package/lib/python3.9/lib-dynload/_testinternalcapi.cpython-39-x86_64-linux-gnu.so +0 -0
  445. package/lib/python3.9/lib-dynload/_testmultiphase.cpython-39-x86_64-linux-gnu.so +0 -0
  446. package/lib/python3.9/lib-dynload/_tkinter.cpython-39-x86_64-linux-gnu.so +0 -0
  447. package/lib/python3.9/lib-dynload/_xxsubinterpreters.cpython-39-x86_64-linux-gnu.so +0 -0
  448. package/lib/python3.9/lib-dynload/_xxtestfuzz.cpython-39-x86_64-linux-gnu.so +0 -0
  449. package/lib/python3.9/lib-dynload/_zoneinfo.cpython-39-x86_64-linux-gnu.so +0 -0
  450. package/lib/python3.9/lib-dynload/array.cpython-39-x86_64-linux-gnu.so +0 -0
  451. package/lib/python3.9/lib-dynload/audioop.cpython-39-x86_64-linux-gnu.so +0 -0
  452. package/lib/python3.9/lib-dynload/binascii.cpython-39-x86_64-linux-gnu.so +0 -0
  453. package/lib/python3.9/lib-dynload/cmath.cpython-39-x86_64-linux-gnu.so +0 -0
  454. package/lib/python3.9/lib-dynload/fcntl.cpython-39-x86_64-linux-gnu.so +0 -0
  455. package/lib/python3.9/lib-dynload/grp.cpython-39-x86_64-linux-gnu.so +0 -0
  456. package/lib/python3.9/lib-dynload/math.cpython-39-x86_64-linux-gnu.so +0 -0
  457. package/lib/python3.9/lib-dynload/mmap.cpython-39-x86_64-linux-gnu.so +0 -0
  458. package/lib/python3.9/lib-dynload/nis.cpython-39-x86_64-linux-gnu.so +0 -0
  459. package/lib/python3.9/lib-dynload/ossaudiodev.cpython-39-x86_64-linux-gnu.so +0 -0
  460. package/lib/python3.9/lib-dynload/parser.cpython-39-x86_64-linux-gnu.so +0 -0
  461. package/lib/python3.9/lib-dynload/pyexpat.cpython-39-x86_64-linux-gnu.so +0 -0
  462. package/lib/python3.9/lib-dynload/readline.cpython-39-x86_64-linux-gnu.so +0 -0
  463. package/lib/python3.9/lib-dynload/resource.cpython-39-x86_64-linux-gnu.so +0 -0
  464. package/lib/python3.9/lib-dynload/select.cpython-39-x86_64-linux-gnu.so +0 -0
  465. package/lib/python3.9/lib-dynload/spwd.cpython-39-x86_64-linux-gnu.so +0 -0
  466. package/lib/python3.9/lib-dynload/syslog.cpython-39-x86_64-linux-gnu.so +0 -0
  467. package/lib/python3.9/lib-dynload/termios.cpython-39-x86_64-linux-gnu.so +0 -0
  468. package/lib/python3.9/lib-dynload/unicodedata.cpython-39-x86_64-linux-gnu.so +0 -0
  469. package/lib/python3.9/lib-dynload/xxlimited.cpython-39-x86_64-linux-gnu.so +0 -0
  470. package/lib/python3.9/lib-dynload/zlib.cpython-39-x86_64-linux-gnu.so +0 -0
  471. package/lib/python3.9/linecache.py +177 -0
  472. package/lib/python3.9/locale.py +1755 -0
  473. package/lib/python3.9/logging/__init__.py +2208 -0
  474. package/lib/python3.9/logging/config.py +945 -0
  475. package/lib/python3.9/logging/handlers.py +1543 -0
  476. package/lib/python3.9/lzma.py +347 -0
  477. package/lib/python3.9/mailbox.py +2151 -0
  478. package/lib/python3.9/mailcap.py +276 -0
  479. package/lib/python3.9/mimetypes.py +614 -0
  480. package/lib/python3.9/modulefinder.py +685 -0
  481. package/lib/python3.9/multiprocessing/__init__.py +37 -0
  482. package/lib/python3.9/multiprocessing/connection.py +978 -0
  483. package/lib/python3.9/multiprocessing/context.py +362 -0
  484. package/lib/python3.9/multiprocessing/dummy/__init__.py +126 -0
  485. package/lib/python3.9/multiprocessing/dummy/connection.py +75 -0
  486. package/lib/python3.9/multiprocessing/forkserver.py +348 -0
  487. package/lib/python3.9/multiprocessing/heap.py +337 -0
  488. package/lib/python3.9/multiprocessing/managers.py +1369 -0
  489. package/lib/python3.9/multiprocessing/pool.py +954 -0
  490. package/lib/python3.9/multiprocessing/popen_fork.py +83 -0
  491. package/lib/python3.9/multiprocessing/popen_forkserver.py +74 -0
  492. package/lib/python3.9/multiprocessing/popen_spawn_posix.py +72 -0
  493. package/lib/python3.9/multiprocessing/popen_spawn_win32.py +131 -0
  494. package/lib/python3.9/multiprocessing/process.py +432 -0
  495. package/lib/python3.9/multiprocessing/queues.py +380 -0
  496. package/lib/python3.9/multiprocessing/reduction.py +281 -0
  497. package/lib/python3.9/multiprocessing/resource_sharer.py +154 -0
  498. package/lib/python3.9/multiprocessing/resource_tracker.py +231 -0
  499. package/lib/python3.9/multiprocessing/shared_memory.py +532 -0
  500. package/lib/python3.9/multiprocessing/sharedctypes.py +240 -0
  501. package/lib/python3.9/multiprocessing/spawn.py +297 -0
  502. package/lib/python3.9/multiprocessing/synchronize.py +394 -0
  503. package/lib/python3.9/multiprocessing/util.py +489 -0
  504. package/lib/python3.9/netrc.py +139 -0
  505. package/lib/python3.9/nntplib.py +1090 -0
  506. package/lib/python3.9/ntpath.py +794 -0
  507. package/lib/python3.9/nturl2path.py +73 -0
  508. package/lib/python3.9/numbers.py +389 -0
  509. package/lib/python3.9/opcode.py +217 -0
  510. package/lib/python3.9/operator.py +460 -0
  511. package/lib/python3.9/optparse.py +1681 -0
  512. package/lib/python3.9/os.py +1116 -0
  513. package/lib/python3.9/pathlib.py +1576 -0
  514. package/lib/python3.9/pdb.py +1731 -0
  515. package/lib/python3.9/pickle.py +1817 -0
  516. package/lib/python3.9/pickletools.py +2890 -0
  517. package/lib/python3.9/pipes.py +247 -0
  518. package/lib/python3.9/pkgutil.py +707 -0
  519. package/lib/python3.9/platform.py +1259 -0
  520. package/lib/python3.9/plistlib.py +881 -0
  521. package/lib/python3.9/poplib.py +483 -0
  522. package/lib/python3.9/posixpath.py +525 -0
  523. package/lib/python3.9/pprint.py +638 -0
  524. package/lib/python3.9/profile.py +600 -0
  525. package/lib/python3.9/pstats.py +779 -0
  526. package/lib/python3.9/pty.py +172 -0
  527. package/lib/python3.9/py_compile.py +215 -0
  528. package/lib/python3.9/pyclbr.py +404 -0
  529. package/lib/python3.9/pydoc.py +2855 -0
  530. package/lib/python3.9/pydoc_data/__init__.py +0 -0
  531. package/lib/python3.9/pydoc_data/_pydoc.css +6 -0
  532. package/lib/python3.9/pydoc_data/topics.py +13968 -0
  533. package/lib/python3.9/queue.py +326 -0
  534. package/lib/python3.9/quopri.py +242 -0
  535. package/lib/python3.9/random.py +887 -0
  536. package/lib/python3.9/re.py +384 -0
  537. package/lib/python3.9/reprlib.py +161 -0
  538. package/lib/python3.9/rlcompleter.py +205 -0
  539. package/lib/python3.9/runpy.py +300 -0
  540. package/lib/python3.9/sched.py +167 -0
  541. package/lib/python3.9/secrets.py +72 -0
  542. package/lib/python3.9/selectors.py +619 -0
  543. package/lib/python3.9/shelve.py +243 -0
  544. package/lib/python3.9/shlex.py +350 -0
  545. package/lib/python3.9/shutil.py +1443 -0
  546. package/lib/python3.9/signal.py +85 -0
  547. package/lib/python3.9/site.py +643 -0
  548. package/lib/python3.9/smtpd.py +967 -0
  549. package/lib/python3.9/smtplib.py +1123 -0
  550. package/lib/python3.9/sndhdr.py +257 -0
  551. package/lib/python3.9/socket.py +958 -0
  552. package/lib/python3.9/socketserver.py +817 -0
  553. package/lib/python3.9/sqlite3/__init__.py +23 -0
  554. package/lib/python3.9/sqlite3/dbapi2.py +89 -0
  555. package/lib/python3.9/sqlite3/dump.py +70 -0
  556. package/lib/python3.9/sre_compile.py +784 -0
  557. package/lib/python3.9/sre_constants.py +259 -0
  558. package/lib/python3.9/sre_parse.py +1064 -0
  559. package/lib/python3.9/ssl.py +1489 -0
  560. package/lib/python3.9/stat.py +195 -0
  561. package/lib/python3.9/statistics.py +1120 -0
  562. package/lib/python3.9/string.py +280 -0
  563. package/lib/python3.9/stringprep.py +272 -0
  564. package/lib/python3.9/struct.py +15 -0
  565. package/lib/python3.9/subprocess.py +2074 -0
  566. package/lib/python3.9/sunau.py +526 -0
  567. package/lib/python3.9/symbol.py +122 -0
  568. package/lib/python3.9/symtable.py +243 -0
  569. package/lib/python3.9/sysconfig.py +720 -0
  570. package/lib/python3.9/tabnanny.py +333 -0
  571. package/lib/python3.9/tarfile.py +2576 -0
  572. package/lib/python3.9/telnetlib.py +677 -0
  573. package/lib/python3.9/tempfile.py +832 -0
  574. package/lib/python3.9/textwrap.py +486 -0
  575. package/lib/python3.9/this.py +28 -0
  576. package/lib/python3.9/threading.py +1502 -0
  577. package/lib/python3.9/timeit.py +375 -0
  578. package/lib/python3.9/token.py +136 -0
  579. package/lib/python3.9/tokenize.py +682 -0
  580. package/lib/python3.9/trace.py +740 -0
  581. package/lib/python3.9/traceback.py +623 -0
  582. package/lib/python3.9/tracemalloc.py +560 -0
  583. package/lib/python3.9/tty.py +36 -0
  584. package/lib/python3.9/turtle.py +4140 -0
  585. package/lib/python3.9/types.py +299 -0
  586. package/lib/python3.9/typing.py +2147 -0
  587. package/lib/python3.9/unittest/__init__.py +95 -0
  588. package/lib/python3.9/unittest/__main__.py +18 -0
  589. package/lib/python3.9/unittest/_log.py +69 -0
  590. package/lib/python3.9/unittest/async_case.py +160 -0
  591. package/lib/python3.9/unittest/case.py +1437 -0
  592. package/lib/python3.9/unittest/loader.py +517 -0
  593. package/lib/python3.9/unittest/main.py +275 -0
  594. package/lib/python3.9/unittest/mock.py +2891 -0
  595. package/lib/python3.9/unittest/result.py +216 -0
  596. package/lib/python3.9/unittest/runner.py +221 -0
  597. package/lib/python3.9/unittest/signals.py +71 -0
  598. package/lib/python3.9/unittest/suite.py +361 -0
  599. package/lib/python3.9/unittest/util.py +170 -0
  600. package/lib/python3.9/urllib/__init__.py +0 -0
  601. package/lib/python3.9/urllib/error.py +77 -0
  602. package/lib/python3.9/urllib/parse.py +1179 -0
  603. package/lib/python3.9/urllib/request.py +2765 -0
  604. package/lib/python3.9/urllib/response.py +84 -0
  605. package/lib/python3.9/urllib/robotparser.py +273 -0
  606. package/lib/python3.9/uu.py +206 -0
  607. package/lib/python3.9/uuid.py +728 -0
  608. package/lib/python3.9/venv/__init__.py +504 -0
  609. package/lib/python3.9/venv/__main__.py +10 -0
  610. package/lib/python3.9/venv/scripts/common/Activate.ps1 +241 -0
  611. package/lib/python3.9/venv/scripts/common/activate +66 -0
  612. package/lib/python3.9/venv/scripts/posix/activate.csh +25 -0
  613. package/lib/python3.9/venv/scripts/posix/activate.fish +64 -0
  614. package/lib/python3.9/warnings.py +549 -0
  615. package/lib/python3.9/wave.py +513 -0
  616. package/lib/python3.9/weakref.py +664 -0
  617. package/lib/python3.9/webbrowser.py +713 -0
  618. package/lib/python3.9/wsgiref/__init__.py +23 -0
  619. package/lib/python3.9/wsgiref/handlers.py +571 -0
  620. package/lib/python3.9/wsgiref/headers.py +184 -0
  621. package/lib/python3.9/wsgiref/simple_server.py +165 -0
  622. package/lib/python3.9/wsgiref/util.py +172 -0
  623. package/lib/python3.9/wsgiref/validate.py +441 -0
  624. package/lib/python3.9/xdrlib.py +241 -0
  625. package/lib/python3.9/xml/__init__.py +20 -0
  626. package/lib/python3.9/xml/dom/NodeFilter.py +27 -0
  627. package/lib/python3.9/xml/dom/__init__.py +140 -0
  628. package/lib/python3.9/xml/dom/domreg.py +99 -0
  629. package/lib/python3.9/xml/dom/expatbuilder.py +965 -0
  630. package/lib/python3.9/xml/dom/minicompat.py +109 -0
  631. package/lib/python3.9/xml/dom/minidom.py +2011 -0
  632. package/lib/python3.9/xml/dom/pulldom.py +349 -0
  633. package/lib/python3.9/xml/dom/xmlbuilder.py +387 -0
  634. package/lib/python3.9/xml/etree/ElementInclude.py +185 -0
  635. package/lib/python3.9/xml/etree/ElementPath.py +405 -0
  636. package/lib/python3.9/xml/etree/ElementTree.py +2085 -0
  637. package/lib/python3.9/xml/etree/__init__.py +33 -0
  638. package/lib/python3.9/xml/etree/cElementTree.py +3 -0
  639. package/lib/python3.9/xml/parsers/__init__.py +8 -0
  640. package/lib/python3.9/xml/parsers/expat.py +8 -0
  641. package/lib/python3.9/xml/sax/__init__.py +107 -0
  642. package/lib/python3.9/xml/sax/_exceptions.py +131 -0
  643. package/lib/python3.9/xml/sax/expatreader.py +446 -0
  644. package/lib/python3.9/xml/sax/handler.py +342 -0
  645. package/lib/python3.9/xml/sax/saxutils.py +369 -0
  646. package/lib/python3.9/xml/sax/xmlreader.py +380 -0
  647. package/lib/python3.9/xmlrpc/__init__.py +1 -0
  648. package/lib/python3.9/xmlrpc/client.py +1524 -0
  649. package/lib/python3.9/xmlrpc/server.py +993 -0
  650. package/lib/python3.9/zipapp.py +206 -0
  651. package/lib/python3.9/zipfile.py +2426 -0
  652. package/lib/python3.9/zipimport.py +792 -0
  653. package/lib/python3.9/zoneinfo/__init__.py +31 -0
  654. package/lib/python3.9/zoneinfo/_common.py +165 -0
  655. package/lib/python3.9/zoneinfo/_tzpath.py +175 -0
  656. package/lib/python3.9/zoneinfo/_zoneinfo.py +752 -0
  657. package/package.json +1 -1
  658. package/runtime.json +1 -0
  659. package/ssl/cacert.pem +3959 -0
  660. package/README.md +0 -59
  661. package/entry.py +0 -5
  662. package/openapi.yaml +0 -739
  663. package/plugin_cli.py +0 -253
  664. package/runtime/cli.ps1 +0 -4
  665. package/runtime/cli.sh +0 -5
  666. package/ted_runner_dpv2/__init__.py +0 -5
  667. package/ted_runner_dpv2/auth.py +0 -95
  668. package/ted_runner_dpv2/executor/__init__.py +0 -8
  669. package/ted_runner_dpv2/executor/isolated.py +0 -111
  670. package/ted_runner_dpv2/executor/launch.py +0 -115
  671. package/ted_runner_dpv2/executor/local.py +0 -43
  672. package/ted_runner_dpv2/executor/plan.py +0 -290
  673. package/ted_runner_dpv2/executor/podman.py +0 -143
  674. package/ted_runner_dpv2/files.py +0 -204
  675. package/ted_runner_dpv2/joblog.py +0 -81
  676. package/ted_runner_dpv2/jobrun/__init__.py +0 -12
  677. package/ted_runner_dpv2/jobrun/artifacts.py +0 -90
  678. package/ted_runner_dpv2/jobrun/environment.py +0 -37
  679. package/ted_runner_dpv2/jobrun/supervisor.py +0 -313
  680. package/ted_runner_dpv2/jobrun/worker.py +0 -55
  681. package/ted_runner_dpv2/jobs.py +0 -300
  682. package/ted_runner_dpv2/jsonio.py +0 -57
  683. package/ted_runner_dpv2/language.py +0 -93
  684. package/ted_runner_dpv2/lease.py +0 -137
  685. package/ted_runner_dpv2/pdk.py +0 -133
  686. package/ted_runner_dpv2/policy.py +0 -73
  687. package/ted_runner_dpv2/relay.py +0 -283
  688. package/ted_runner_dpv2/service.py +0 -512
  689. package/ted_runner_dpv2/worker.py +0 -430
  690. package/tedbrain_plugin_runtime/__init__.py +0 -2
  691. package/tedbrain_plugin_runtime/admission.py +0 -39
  692. package/tedbrain_plugin_runtime/auth.py +0 -92
  693. package/tedbrain_plugin_runtime/bootstrap.py +0 -110
  694. package/tedbrain_plugin_runtime/cli.py +0 -238
  695. package/tedbrain_plugin_runtime/engine.py +0 -132
  696. package/tedbrain_plugin_runtime/executor.py +0 -115
  697. package/tedbrain_plugin_runtime/handoff.py +0 -193
  698. package/tedbrain_plugin_runtime/installer.py +0 -400
  699. package/tedbrain_plugin_runtime/jobs.py +0 -293
  700. package/tedbrain_plugin_runtime/launcher.py +0 -122
  701. package/tedbrain_plugin_runtime/ops.py +0 -311
  702. package/tedbrain_plugin_runtime/publication.py +0 -53
  703. package/tedbrain_plugin_runtime/request_contract.py +0 -226
  704. package/tedbrain_plugin_runtime/rungc.py +0 -178
  705. package/tedbrain_plugin_runtime/service.py +0 -382
  706. package/tedbrain_plugin_runtime/sessions.py +0 -96
  707. package/tedbrain_plugin_runtime/ssh_workstation.py +0 -40
  708. package/tedbrain_plugin_runtime/supervisor.py +0 -165
  709. package/tedbrain_plugin_runtime/worker.py +0 -345
  710. package/tedbrain_plugin_runtime/workstations.py +0 -170
@@ -0,0 +1,1466 @@
1
+ """Selector event loop for Unix with signal handling."""
2
+
3
+ import errno
4
+ import io
5
+ import itertools
6
+ import os
7
+ import selectors
8
+ import signal
9
+ import socket
10
+ import stat
11
+ import subprocess
12
+ import sys
13
+ import threading
14
+ import warnings
15
+
16
+ from . import base_events
17
+ from . import base_subprocess
18
+ from . import constants
19
+ from . import coroutines
20
+ from . import events
21
+ from . import exceptions
22
+ from . import futures
23
+ from . import selector_events
24
+ from . import tasks
25
+ from . import transports
26
+ from .log import logger
27
+
28
+
29
+ __all__ = (
30
+ 'SelectorEventLoop',
31
+ 'AbstractChildWatcher', 'SafeChildWatcher',
32
+ 'FastChildWatcher', 'PidfdChildWatcher',
33
+ 'MultiLoopChildWatcher', 'ThreadedChildWatcher',
34
+ 'DefaultEventLoopPolicy',
35
+ )
36
+
37
+
38
+ if sys.platform == 'win32': # pragma: no cover
39
+ raise ImportError('Signals are not really supported on Windows')
40
+
41
+
42
+ def _sighandler_noop(signum, frame):
43
+ """Dummy signal handler."""
44
+ pass
45
+
46
+
47
+ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
48
+ """Unix event loop.
49
+
50
+ Adds signal handling and UNIX Domain Socket support to SelectorEventLoop.
51
+ """
52
+
53
+ def __init__(self, selector=None):
54
+ super().__init__(selector)
55
+ self._signal_handlers = {}
56
+
57
+ def close(self):
58
+ super().close()
59
+ if not sys.is_finalizing():
60
+ for sig in list(self._signal_handlers):
61
+ self.remove_signal_handler(sig)
62
+ else:
63
+ if self._signal_handlers:
64
+ warnings.warn(f"Closing the loop {self!r} "
65
+ f"on interpreter shutdown "
66
+ f"stage, skipping signal handlers removal",
67
+ ResourceWarning,
68
+ source=self)
69
+ self._signal_handlers.clear()
70
+
71
+ def _process_self_data(self, data):
72
+ for signum in data:
73
+ if not signum:
74
+ # ignore null bytes written by _write_to_self()
75
+ continue
76
+ self._handle_signal(signum)
77
+
78
+ def add_signal_handler(self, sig, callback, *args):
79
+ """Add a handler for a signal. UNIX only.
80
+
81
+ Raise ValueError if the signal number is invalid or uncatchable.
82
+ Raise RuntimeError if there is a problem setting up the handler.
83
+ """
84
+ if (coroutines.iscoroutine(callback) or
85
+ coroutines.iscoroutinefunction(callback)):
86
+ raise TypeError("coroutines cannot be used "
87
+ "with add_signal_handler()")
88
+ self._check_signal(sig)
89
+ self._check_closed()
90
+ try:
91
+ # set_wakeup_fd() raises ValueError if this is not the
92
+ # main thread. By calling it early we ensure that an
93
+ # event loop running in another thread cannot add a signal
94
+ # handler.
95
+ signal.set_wakeup_fd(self._csock.fileno())
96
+ except (ValueError, OSError) as exc:
97
+ raise RuntimeError(str(exc))
98
+
99
+ handle = events.Handle(callback, args, self, None)
100
+ self._signal_handlers[sig] = handle
101
+
102
+ try:
103
+ # Register a dummy signal handler to ask Python to write the signal
104
+ # number in the wakeup file descriptor. _process_self_data() will
105
+ # read signal numbers from this file descriptor to handle signals.
106
+ signal.signal(sig, _sighandler_noop)
107
+
108
+ # Set SA_RESTART to limit EINTR occurrences.
109
+ signal.siginterrupt(sig, False)
110
+ except OSError as exc:
111
+ del self._signal_handlers[sig]
112
+ if not self._signal_handlers:
113
+ try:
114
+ signal.set_wakeup_fd(-1)
115
+ except (ValueError, OSError) as nexc:
116
+ logger.info('set_wakeup_fd(-1) failed: %s', nexc)
117
+
118
+ if exc.errno == errno.EINVAL:
119
+ raise RuntimeError(f'sig {sig} cannot be caught')
120
+ else:
121
+ raise
122
+
123
+ def _handle_signal(self, sig):
124
+ """Internal helper that is the actual signal handler."""
125
+ handle = self._signal_handlers.get(sig)
126
+ if handle is None:
127
+ return # Assume it's some race condition.
128
+ if handle._cancelled:
129
+ self.remove_signal_handler(sig) # Remove it properly.
130
+ else:
131
+ self._add_callback_signalsafe(handle)
132
+
133
+ def remove_signal_handler(self, sig):
134
+ """Remove a handler for a signal. UNIX only.
135
+
136
+ Return True if a signal handler was removed, False if not.
137
+ """
138
+ self._check_signal(sig)
139
+ try:
140
+ del self._signal_handlers[sig]
141
+ except KeyError:
142
+ return False
143
+
144
+ if sig == signal.SIGINT:
145
+ handler = signal.default_int_handler
146
+ else:
147
+ handler = signal.SIG_DFL
148
+
149
+ try:
150
+ signal.signal(sig, handler)
151
+ except OSError as exc:
152
+ if exc.errno == errno.EINVAL:
153
+ raise RuntimeError(f'sig {sig} cannot be caught')
154
+ else:
155
+ raise
156
+
157
+ if not self._signal_handlers:
158
+ try:
159
+ signal.set_wakeup_fd(-1)
160
+ except (ValueError, OSError) as exc:
161
+ logger.info('set_wakeup_fd(-1) failed: %s', exc)
162
+
163
+ return True
164
+
165
+ def _check_signal(self, sig):
166
+ """Internal helper to validate a signal.
167
+
168
+ Raise ValueError if the signal number is invalid or uncatchable.
169
+ Raise RuntimeError if there is a problem setting up the handler.
170
+ """
171
+ if not isinstance(sig, int):
172
+ raise TypeError(f'sig must be an int, not {sig!r}')
173
+
174
+ if sig not in signal.valid_signals():
175
+ raise ValueError(f'invalid signal number {sig}')
176
+
177
+ def _make_read_pipe_transport(self, pipe, protocol, waiter=None,
178
+ extra=None):
179
+ return _UnixReadPipeTransport(self, pipe, protocol, waiter, extra)
180
+
181
+ def _make_write_pipe_transport(self, pipe, protocol, waiter=None,
182
+ extra=None):
183
+ return _UnixWritePipeTransport(self, pipe, protocol, waiter, extra)
184
+
185
+ async def _make_subprocess_transport(self, protocol, args, shell,
186
+ stdin, stdout, stderr, bufsize,
187
+ extra=None, **kwargs):
188
+ with events.get_child_watcher() as watcher:
189
+ if not watcher.is_active():
190
+ # Check early.
191
+ # Raising exception before process creation
192
+ # prevents subprocess execution if the watcher
193
+ # is not ready to handle it.
194
+ raise RuntimeError("asyncio.get_child_watcher() is not activated, "
195
+ "subprocess support is not installed.")
196
+ waiter = self.create_future()
197
+ transp = _UnixSubprocessTransport(self, protocol, args, shell,
198
+ stdin, stdout, stderr, bufsize,
199
+ waiter=waiter, extra=extra,
200
+ **kwargs)
201
+
202
+ watcher.add_child_handler(transp.get_pid(),
203
+ self._child_watcher_callback, transp)
204
+ try:
205
+ await waiter
206
+ except (SystemExit, KeyboardInterrupt):
207
+ raise
208
+ except BaseException:
209
+ transp.close()
210
+ await transp._wait()
211
+ raise
212
+
213
+ return transp
214
+
215
+ def _child_watcher_callback(self, pid, returncode, transp):
216
+ self.call_soon_threadsafe(transp._process_exited, returncode)
217
+
218
+ async def create_unix_connection(
219
+ self, protocol_factory, path=None, *,
220
+ ssl=None, sock=None,
221
+ server_hostname=None,
222
+ ssl_handshake_timeout=None):
223
+ assert server_hostname is None or isinstance(server_hostname, str)
224
+ if ssl:
225
+ if server_hostname is None:
226
+ raise ValueError(
227
+ 'you have to pass server_hostname when using ssl')
228
+ else:
229
+ if server_hostname is not None:
230
+ raise ValueError('server_hostname is only meaningful with ssl')
231
+ if ssl_handshake_timeout is not None:
232
+ raise ValueError(
233
+ 'ssl_handshake_timeout is only meaningful with ssl')
234
+
235
+ if path is not None:
236
+ if sock is not None:
237
+ raise ValueError(
238
+ 'path and sock can not be specified at the same time')
239
+
240
+ path = os.fspath(path)
241
+ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
242
+ try:
243
+ sock.setblocking(False)
244
+ await self.sock_connect(sock, path)
245
+ except:
246
+ sock.close()
247
+ raise
248
+
249
+ else:
250
+ if sock is None:
251
+ raise ValueError('no path and sock were specified')
252
+ if (sock.family != socket.AF_UNIX or
253
+ sock.type != socket.SOCK_STREAM):
254
+ raise ValueError(
255
+ f'A UNIX Domain Stream Socket was expected, got {sock!r}')
256
+ sock.setblocking(False)
257
+
258
+ transport, protocol = await self._create_connection_transport(
259
+ sock, protocol_factory, ssl, server_hostname,
260
+ ssl_handshake_timeout=ssl_handshake_timeout)
261
+ return transport, protocol
262
+
263
+ async def create_unix_server(
264
+ self, protocol_factory, path=None, *,
265
+ sock=None, backlog=100, ssl=None,
266
+ ssl_handshake_timeout=None,
267
+ start_serving=True):
268
+ if isinstance(ssl, bool):
269
+ raise TypeError('ssl argument must be an SSLContext or None')
270
+
271
+ if ssl_handshake_timeout is not None and not ssl:
272
+ raise ValueError(
273
+ 'ssl_handshake_timeout is only meaningful with ssl')
274
+
275
+ if path is not None:
276
+ if sock is not None:
277
+ raise ValueError(
278
+ 'path and sock can not be specified at the same time')
279
+
280
+ path = os.fspath(path)
281
+ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
282
+
283
+ # Check for abstract socket. `str` and `bytes` paths are supported.
284
+ if path[0] not in (0, '\x00'):
285
+ try:
286
+ if stat.S_ISSOCK(os.stat(path).st_mode):
287
+ os.remove(path)
288
+ except FileNotFoundError:
289
+ pass
290
+ except OSError as err:
291
+ # Directory may have permissions only to create socket.
292
+ logger.error('Unable to check or remove stale UNIX socket '
293
+ '%r: %r', path, err)
294
+
295
+ try:
296
+ sock.bind(path)
297
+ except OSError as exc:
298
+ sock.close()
299
+ if exc.errno == errno.EADDRINUSE:
300
+ # Let's improve the error message by adding
301
+ # with what exact address it occurs.
302
+ msg = f'Address {path!r} is already in use'
303
+ raise OSError(errno.EADDRINUSE, msg) from None
304
+ else:
305
+ raise
306
+ except:
307
+ sock.close()
308
+ raise
309
+ else:
310
+ if sock is None:
311
+ raise ValueError(
312
+ 'path was not specified, and no sock specified')
313
+
314
+ if (sock.family != socket.AF_UNIX or
315
+ sock.type != socket.SOCK_STREAM):
316
+ raise ValueError(
317
+ f'A UNIX Domain Stream Socket was expected, got {sock!r}')
318
+
319
+ sock.setblocking(False)
320
+ server = base_events.Server(self, [sock], protocol_factory,
321
+ ssl, backlog, ssl_handshake_timeout)
322
+ if start_serving:
323
+ server._start_serving()
324
+ # Skip one loop iteration so that all 'loop.add_reader'
325
+ # go through.
326
+ await tasks.sleep(0, loop=self)
327
+
328
+ return server
329
+
330
+ async def _sock_sendfile_native(self, sock, file, offset, count):
331
+ try:
332
+ os.sendfile
333
+ except AttributeError:
334
+ raise exceptions.SendfileNotAvailableError(
335
+ "os.sendfile() is not available")
336
+ try:
337
+ fileno = file.fileno()
338
+ except (AttributeError, io.UnsupportedOperation) as err:
339
+ raise exceptions.SendfileNotAvailableError("not a regular file")
340
+ try:
341
+ fsize = os.fstat(fileno).st_size
342
+ except OSError:
343
+ raise exceptions.SendfileNotAvailableError("not a regular file")
344
+ blocksize = count if count else fsize
345
+ if not blocksize:
346
+ return 0 # empty file
347
+
348
+ fut = self.create_future()
349
+ self._sock_sendfile_native_impl(fut, None, sock, fileno,
350
+ offset, count, blocksize, 0)
351
+ return await fut
352
+
353
+ def _sock_sendfile_native_impl(self, fut, registered_fd, sock, fileno,
354
+ offset, count, blocksize, total_sent):
355
+ fd = sock.fileno()
356
+ if registered_fd is not None:
357
+ # Remove the callback early. It should be rare that the
358
+ # selector says the fd is ready but the call still returns
359
+ # EAGAIN, and I am willing to take a hit in that case in
360
+ # order to simplify the common case.
361
+ self.remove_writer(registered_fd)
362
+ if fut.cancelled():
363
+ self._sock_sendfile_update_filepos(fileno, offset, total_sent)
364
+ return
365
+ if count:
366
+ blocksize = count - total_sent
367
+ if blocksize <= 0:
368
+ self._sock_sendfile_update_filepos(fileno, offset, total_sent)
369
+ fut.set_result(total_sent)
370
+ return
371
+
372
+ try:
373
+ sent = os.sendfile(fd, fileno, offset, blocksize)
374
+ except (BlockingIOError, InterruptedError):
375
+ if registered_fd is None:
376
+ self._sock_add_cancellation_callback(fut, sock)
377
+ self.add_writer(fd, self._sock_sendfile_native_impl, fut,
378
+ fd, sock, fileno,
379
+ offset, count, blocksize, total_sent)
380
+ except OSError as exc:
381
+ if (registered_fd is not None and
382
+ exc.errno == errno.ENOTCONN and
383
+ type(exc) is not ConnectionError):
384
+ # If we have an ENOTCONN and this isn't a first call to
385
+ # sendfile(), i.e. the connection was closed in the middle
386
+ # of the operation, normalize the error to ConnectionError
387
+ # to make it consistent across all Posix systems.
388
+ new_exc = ConnectionError(
389
+ "socket is not connected", errno.ENOTCONN)
390
+ new_exc.__cause__ = exc
391
+ exc = new_exc
392
+ if total_sent == 0:
393
+ # We can get here for different reasons, the main
394
+ # one being 'file' is not a regular mmap(2)-like
395
+ # file, in which case we'll fall back on using
396
+ # plain send().
397
+ err = exceptions.SendfileNotAvailableError(
398
+ "os.sendfile call failed")
399
+ self._sock_sendfile_update_filepos(fileno, offset, total_sent)
400
+ fut.set_exception(err)
401
+ else:
402
+ self._sock_sendfile_update_filepos(fileno, offset, total_sent)
403
+ fut.set_exception(exc)
404
+ except (SystemExit, KeyboardInterrupt):
405
+ raise
406
+ except BaseException as exc:
407
+ self._sock_sendfile_update_filepos(fileno, offset, total_sent)
408
+ fut.set_exception(exc)
409
+ else:
410
+ if sent == 0:
411
+ # EOF
412
+ self._sock_sendfile_update_filepos(fileno, offset, total_sent)
413
+ fut.set_result(total_sent)
414
+ else:
415
+ offset += sent
416
+ total_sent += sent
417
+ if registered_fd is None:
418
+ self._sock_add_cancellation_callback(fut, sock)
419
+ self.add_writer(fd, self._sock_sendfile_native_impl, fut,
420
+ fd, sock, fileno,
421
+ offset, count, blocksize, total_sent)
422
+
423
+ def _sock_sendfile_update_filepos(self, fileno, offset, total_sent):
424
+ if total_sent > 0:
425
+ os.lseek(fileno, offset, os.SEEK_SET)
426
+
427
+ def _sock_add_cancellation_callback(self, fut, sock):
428
+ def cb(fut):
429
+ if fut.cancelled():
430
+ fd = sock.fileno()
431
+ if fd != -1:
432
+ self.remove_writer(fd)
433
+ fut.add_done_callback(cb)
434
+
435
+
436
+ class _UnixReadPipeTransport(transports.ReadTransport):
437
+
438
+ max_size = 256 * 1024 # max bytes we read in one event loop iteration
439
+
440
+ def __init__(self, loop, pipe, protocol, waiter=None, extra=None):
441
+ super().__init__(extra)
442
+ self._extra['pipe'] = pipe
443
+ self._loop = loop
444
+ self._pipe = pipe
445
+ self._fileno = pipe.fileno()
446
+ self._protocol = protocol
447
+ self._closing = False
448
+ self._paused = False
449
+
450
+ mode = os.fstat(self._fileno).st_mode
451
+ if not (stat.S_ISFIFO(mode) or
452
+ stat.S_ISSOCK(mode) or
453
+ stat.S_ISCHR(mode)):
454
+ self._pipe = None
455
+ self._fileno = None
456
+ self._protocol = None
457
+ raise ValueError("Pipe transport is for pipes/sockets only.")
458
+
459
+ os.set_blocking(self._fileno, False)
460
+
461
+ self._loop.call_soon(self._protocol.connection_made, self)
462
+ # only start reading when connection_made() has been called
463
+ self._loop.call_soon(self._loop._add_reader,
464
+ self._fileno, self._read_ready)
465
+ if waiter is not None:
466
+ # only wake up the waiter when connection_made() has been called
467
+ self._loop.call_soon(futures._set_result_unless_cancelled,
468
+ waiter, None)
469
+
470
+ def __repr__(self):
471
+ info = [self.__class__.__name__]
472
+ if self._pipe is None:
473
+ info.append('closed')
474
+ elif self._closing:
475
+ info.append('closing')
476
+ info.append(f'fd={self._fileno}')
477
+ selector = getattr(self._loop, '_selector', None)
478
+ if self._pipe is not None and selector is not None:
479
+ polling = selector_events._test_selector_event(
480
+ selector, self._fileno, selectors.EVENT_READ)
481
+ if polling:
482
+ info.append('polling')
483
+ else:
484
+ info.append('idle')
485
+ elif self._pipe is not None:
486
+ info.append('open')
487
+ else:
488
+ info.append('closed')
489
+ return '<{}>'.format(' '.join(info))
490
+
491
+ def _read_ready(self):
492
+ try:
493
+ data = os.read(self._fileno, self.max_size)
494
+ except (BlockingIOError, InterruptedError):
495
+ pass
496
+ except OSError as exc:
497
+ self._fatal_error(exc, 'Fatal read error on pipe transport')
498
+ else:
499
+ if data:
500
+ self._protocol.data_received(data)
501
+ else:
502
+ if self._loop.get_debug():
503
+ logger.info("%r was closed by peer", self)
504
+ self._closing = True
505
+ self._loop._remove_reader(self._fileno)
506
+ self._loop.call_soon(self._protocol.eof_received)
507
+ self._loop.call_soon(self._call_connection_lost, None)
508
+
509
+ def pause_reading(self):
510
+ if self._closing or self._paused:
511
+ return
512
+ self._paused = True
513
+ self._loop._remove_reader(self._fileno)
514
+ if self._loop.get_debug():
515
+ logger.debug("%r pauses reading", self)
516
+
517
+ def resume_reading(self):
518
+ if self._closing or not self._paused:
519
+ return
520
+ self._paused = False
521
+ self._loop._add_reader(self._fileno, self._read_ready)
522
+ if self._loop.get_debug():
523
+ logger.debug("%r resumes reading", self)
524
+
525
+ def set_protocol(self, protocol):
526
+ self._protocol = protocol
527
+
528
+ def get_protocol(self):
529
+ return self._protocol
530
+
531
+ def is_closing(self):
532
+ return self._closing
533
+
534
+ def close(self):
535
+ if not self._closing:
536
+ self._close(None)
537
+
538
+ def __del__(self, _warn=warnings.warn):
539
+ if self._pipe is not None:
540
+ _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
541
+ self._pipe.close()
542
+
543
+ def _fatal_error(self, exc, message='Fatal error on pipe transport'):
544
+ # should be called by exception handler only
545
+ if (isinstance(exc, OSError) and exc.errno == errno.EIO):
546
+ if self._loop.get_debug():
547
+ logger.debug("%r: %s", self, message, exc_info=True)
548
+ else:
549
+ self._loop.call_exception_handler({
550
+ 'message': message,
551
+ 'exception': exc,
552
+ 'transport': self,
553
+ 'protocol': self._protocol,
554
+ })
555
+ self._close(exc)
556
+
557
+ def _close(self, exc):
558
+ self._closing = True
559
+ self._loop._remove_reader(self._fileno)
560
+ self._loop.call_soon(self._call_connection_lost, exc)
561
+
562
+ def _call_connection_lost(self, exc):
563
+ try:
564
+ self._protocol.connection_lost(exc)
565
+ finally:
566
+ self._pipe.close()
567
+ self._pipe = None
568
+ self._protocol = None
569
+ self._loop = None
570
+
571
+
572
+ class _UnixWritePipeTransport(transports._FlowControlMixin,
573
+ transports.WriteTransport):
574
+
575
+ def __init__(self, loop, pipe, protocol, waiter=None, extra=None):
576
+ super().__init__(extra, loop)
577
+ self._extra['pipe'] = pipe
578
+ self._pipe = pipe
579
+ self._fileno = pipe.fileno()
580
+ self._protocol = protocol
581
+ self._buffer = bytearray()
582
+ self._conn_lost = 0
583
+ self._closing = False # Set when close() or write_eof() called.
584
+
585
+ mode = os.fstat(self._fileno).st_mode
586
+ is_char = stat.S_ISCHR(mode)
587
+ is_fifo = stat.S_ISFIFO(mode)
588
+ is_socket = stat.S_ISSOCK(mode)
589
+ if not (is_char or is_fifo or is_socket):
590
+ self._pipe = None
591
+ self._fileno = None
592
+ self._protocol = None
593
+ raise ValueError("Pipe transport is only for "
594
+ "pipes, sockets and character devices")
595
+
596
+ os.set_blocking(self._fileno, False)
597
+ self._loop.call_soon(self._protocol.connection_made, self)
598
+
599
+ # On AIX, the reader trick (to be notified when the read end of the
600
+ # socket is closed) only works for sockets. On other platforms it
601
+ # works for pipes and sockets. (Exception: OS X 10.4? Issue #19294.)
602
+ if is_socket or (is_fifo and not sys.platform.startswith("aix")):
603
+ # only start reading when connection_made() has been called
604
+ self._loop.call_soon(self._loop._add_reader,
605
+ self._fileno, self._read_ready)
606
+
607
+ if waiter is not None:
608
+ # only wake up the waiter when connection_made() has been called
609
+ self._loop.call_soon(futures._set_result_unless_cancelled,
610
+ waiter, None)
611
+
612
+ def __repr__(self):
613
+ info = [self.__class__.__name__]
614
+ if self._pipe is None:
615
+ info.append('closed')
616
+ elif self._closing:
617
+ info.append('closing')
618
+ info.append(f'fd={self._fileno}')
619
+ selector = getattr(self._loop, '_selector', None)
620
+ if self._pipe is not None and selector is not None:
621
+ polling = selector_events._test_selector_event(
622
+ selector, self._fileno, selectors.EVENT_WRITE)
623
+ if polling:
624
+ info.append('polling')
625
+ else:
626
+ info.append('idle')
627
+
628
+ bufsize = self.get_write_buffer_size()
629
+ info.append(f'bufsize={bufsize}')
630
+ elif self._pipe is not None:
631
+ info.append('open')
632
+ else:
633
+ info.append('closed')
634
+ return '<{}>'.format(' '.join(info))
635
+
636
+ def get_write_buffer_size(self):
637
+ return len(self._buffer)
638
+
639
+ def _read_ready(self):
640
+ # Pipe was closed by peer.
641
+ if self._loop.get_debug():
642
+ logger.info("%r was closed by peer", self)
643
+ if self._buffer:
644
+ self._close(BrokenPipeError())
645
+ else:
646
+ self._close()
647
+
648
+ def write(self, data):
649
+ assert isinstance(data, (bytes, bytearray, memoryview)), repr(data)
650
+ if isinstance(data, bytearray):
651
+ data = memoryview(data)
652
+ if not data:
653
+ return
654
+
655
+ if self._conn_lost or self._closing:
656
+ if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES:
657
+ logger.warning('pipe closed by peer or '
658
+ 'os.write(pipe, data) raised exception.')
659
+ self._conn_lost += 1
660
+ return
661
+
662
+ if not self._buffer:
663
+ # Attempt to send it right away first.
664
+ try:
665
+ n = os.write(self._fileno, data)
666
+ except (BlockingIOError, InterruptedError):
667
+ n = 0
668
+ except (SystemExit, KeyboardInterrupt):
669
+ raise
670
+ except BaseException as exc:
671
+ self._conn_lost += 1
672
+ self._fatal_error(exc, 'Fatal write error on pipe transport')
673
+ return
674
+ if n == len(data):
675
+ return
676
+ elif n > 0:
677
+ data = memoryview(data)[n:]
678
+ self._loop._add_writer(self._fileno, self._write_ready)
679
+
680
+ self._buffer += data
681
+ self._maybe_pause_protocol()
682
+
683
+ def _write_ready(self):
684
+ assert self._buffer, 'Data should not be empty'
685
+
686
+ try:
687
+ n = os.write(self._fileno, self._buffer)
688
+ except (BlockingIOError, InterruptedError):
689
+ pass
690
+ except (SystemExit, KeyboardInterrupt):
691
+ raise
692
+ except BaseException as exc:
693
+ self._buffer.clear()
694
+ self._conn_lost += 1
695
+ # Remove writer here, _fatal_error() doesn't it
696
+ # because _buffer is empty.
697
+ self._loop._remove_writer(self._fileno)
698
+ self._fatal_error(exc, 'Fatal write error on pipe transport')
699
+ else:
700
+ if n == len(self._buffer):
701
+ self._buffer.clear()
702
+ self._loop._remove_writer(self._fileno)
703
+ self._maybe_resume_protocol() # May append to buffer.
704
+ if self._closing:
705
+ self._loop._remove_reader(self._fileno)
706
+ self._call_connection_lost(None)
707
+ return
708
+ elif n > 0:
709
+ del self._buffer[:n]
710
+
711
+ def can_write_eof(self):
712
+ return True
713
+
714
+ def write_eof(self):
715
+ if self._closing:
716
+ return
717
+ assert self._pipe
718
+ self._closing = True
719
+ if not self._buffer:
720
+ self._loop._remove_reader(self._fileno)
721
+ self._loop.call_soon(self._call_connection_lost, None)
722
+
723
+ def set_protocol(self, protocol):
724
+ self._protocol = protocol
725
+
726
+ def get_protocol(self):
727
+ return self._protocol
728
+
729
+ def is_closing(self):
730
+ return self._closing
731
+
732
+ def close(self):
733
+ if self._pipe is not None and not self._closing:
734
+ # write_eof is all what we needed to close the write pipe
735
+ self.write_eof()
736
+
737
+ def __del__(self, _warn=warnings.warn):
738
+ if self._pipe is not None:
739
+ _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
740
+ self._pipe.close()
741
+
742
+ def abort(self):
743
+ self._close(None)
744
+
745
+ def _fatal_error(self, exc, message='Fatal error on pipe transport'):
746
+ # should be called by exception handler only
747
+ if isinstance(exc, OSError):
748
+ if self._loop.get_debug():
749
+ logger.debug("%r: %s", self, message, exc_info=True)
750
+ else:
751
+ self._loop.call_exception_handler({
752
+ 'message': message,
753
+ 'exception': exc,
754
+ 'transport': self,
755
+ 'protocol': self._protocol,
756
+ })
757
+ self._close(exc)
758
+
759
+ def _close(self, exc=None):
760
+ self._closing = True
761
+ if self._buffer:
762
+ self._loop._remove_writer(self._fileno)
763
+ self._buffer.clear()
764
+ self._loop._remove_reader(self._fileno)
765
+ self._loop.call_soon(self._call_connection_lost, exc)
766
+
767
+ def _call_connection_lost(self, exc):
768
+ try:
769
+ self._protocol.connection_lost(exc)
770
+ finally:
771
+ self._pipe.close()
772
+ self._pipe = None
773
+ self._protocol = None
774
+ self._loop = None
775
+
776
+
777
+ class _UnixSubprocessTransport(base_subprocess.BaseSubprocessTransport):
778
+
779
+ def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs):
780
+ stdin_w = None
781
+ if stdin == subprocess.PIPE:
782
+ # Use a socket pair for stdin, since not all platforms
783
+ # support selecting read events on the write end of a
784
+ # socket (which we use in order to detect closing of the
785
+ # other end). Notably this is needed on AIX, and works
786
+ # just fine on other platforms.
787
+ stdin, stdin_w = socket.socketpair()
788
+ try:
789
+ self._proc = subprocess.Popen(
790
+ args, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr,
791
+ universal_newlines=False, bufsize=bufsize, **kwargs)
792
+ if stdin_w is not None:
793
+ stdin.close()
794
+ self._proc.stdin = open(stdin_w.detach(), 'wb', buffering=bufsize)
795
+ stdin_w = None
796
+ finally:
797
+ if stdin_w is not None:
798
+ stdin.close()
799
+ stdin_w.close()
800
+
801
+
802
+ class AbstractChildWatcher:
803
+ """Abstract base class for monitoring child processes.
804
+
805
+ Objects derived from this class monitor a collection of subprocesses and
806
+ report their termination or interruption by a signal.
807
+
808
+ New callbacks are registered with .add_child_handler(). Starting a new
809
+ process must be done within a 'with' block to allow the watcher to suspend
810
+ its activity until the new process if fully registered (this is needed to
811
+ prevent a race condition in some implementations).
812
+
813
+ Example:
814
+ with watcher:
815
+ proc = subprocess.Popen("sleep 1")
816
+ watcher.add_child_handler(proc.pid, callback)
817
+
818
+ Notes:
819
+ Implementations of this class must be thread-safe.
820
+
821
+ Since child watcher objects may catch the SIGCHLD signal and call
822
+ waitpid(-1), there should be only one active object per process.
823
+ """
824
+
825
+ def add_child_handler(self, pid, callback, *args):
826
+ """Register a new child handler.
827
+
828
+ Arrange for callback(pid, returncode, *args) to be called when
829
+ process 'pid' terminates. Specifying another callback for the same
830
+ process replaces the previous handler.
831
+
832
+ Note: callback() must be thread-safe.
833
+ """
834
+ raise NotImplementedError()
835
+
836
+ def remove_child_handler(self, pid):
837
+ """Removes the handler for process 'pid'.
838
+
839
+ The function returns True if the handler was successfully removed,
840
+ False if there was nothing to remove."""
841
+
842
+ raise NotImplementedError()
843
+
844
+ def attach_loop(self, loop):
845
+ """Attach the watcher to an event loop.
846
+
847
+ If the watcher was previously attached to an event loop, then it is
848
+ first detached before attaching to the new loop.
849
+
850
+ Note: loop may be None.
851
+ """
852
+ raise NotImplementedError()
853
+
854
+ def close(self):
855
+ """Close the watcher.
856
+
857
+ This must be called to make sure that any underlying resource is freed.
858
+ """
859
+ raise NotImplementedError()
860
+
861
+ def is_active(self):
862
+ """Return ``True`` if the watcher is active and is used by the event loop.
863
+
864
+ Return True if the watcher is installed and ready to handle process exit
865
+ notifications.
866
+
867
+ """
868
+ raise NotImplementedError()
869
+
870
+ def __enter__(self):
871
+ """Enter the watcher's context and allow starting new processes
872
+
873
+ This function must return self"""
874
+ raise NotImplementedError()
875
+
876
+ def __exit__(self, a, b, c):
877
+ """Exit the watcher's context"""
878
+ raise NotImplementedError()
879
+
880
+
881
+ class PidfdChildWatcher(AbstractChildWatcher):
882
+ """Child watcher implementation using Linux's pid file descriptors.
883
+
884
+ This child watcher polls process file descriptors (pidfds) to await child
885
+ process termination. In some respects, PidfdChildWatcher is a "Goldilocks"
886
+ child watcher implementation. It doesn't require signals or threads, doesn't
887
+ interfere with any processes launched outside the event loop, and scales
888
+ linearly with the number of subprocesses launched by the event loop. The
889
+ main disadvantage is that pidfds are specific to Linux, and only work on
890
+ recent (5.3+) kernels.
891
+ """
892
+
893
+ def __init__(self):
894
+ self._loop = None
895
+ self._callbacks = {}
896
+
897
+ def __enter__(self):
898
+ return self
899
+
900
+ def __exit__(self, exc_type, exc_value, exc_traceback):
901
+ pass
902
+
903
+ def is_active(self):
904
+ return self._loop is not None and self._loop.is_running()
905
+
906
+ def close(self):
907
+ self.attach_loop(None)
908
+
909
+ def attach_loop(self, loop):
910
+ if self._loop is not None and loop is None and self._callbacks:
911
+ warnings.warn(
912
+ 'A loop is being detached '
913
+ 'from a child watcher with pending handlers',
914
+ RuntimeWarning)
915
+ for pidfd, _, _ in self._callbacks.values():
916
+ self._loop._remove_reader(pidfd)
917
+ os.close(pidfd)
918
+ self._callbacks.clear()
919
+ self._loop = loop
920
+
921
+ def add_child_handler(self, pid, callback, *args):
922
+ existing = self._callbacks.get(pid)
923
+ if existing is not None:
924
+ self._callbacks[pid] = existing[0], callback, args
925
+ else:
926
+ pidfd = os.pidfd_open(pid)
927
+ self._loop._add_reader(pidfd, self._do_wait, pid)
928
+ self._callbacks[pid] = pidfd, callback, args
929
+
930
+ def _do_wait(self, pid):
931
+ pidfd, callback, args = self._callbacks.pop(pid)
932
+ self._loop._remove_reader(pidfd)
933
+ try:
934
+ _, status = os.waitpid(pid, 0)
935
+ except ChildProcessError:
936
+ # The child process is already reaped
937
+ # (may happen if waitpid() is called elsewhere).
938
+ returncode = 255
939
+ logger.warning(
940
+ "child process pid %d exit status already read: "
941
+ " will report returncode 255",
942
+ pid)
943
+ else:
944
+ returncode = _compute_returncode(status)
945
+
946
+ os.close(pidfd)
947
+ callback(pid, returncode, *args)
948
+
949
+ def remove_child_handler(self, pid):
950
+ try:
951
+ pidfd, _, _ = self._callbacks.pop(pid)
952
+ except KeyError:
953
+ return False
954
+ self._loop._remove_reader(pidfd)
955
+ os.close(pidfd)
956
+ return True
957
+
958
+
959
+ def _compute_returncode(status):
960
+ if os.WIFSIGNALED(status):
961
+ # The child process died because of a signal.
962
+ return -os.WTERMSIG(status)
963
+ elif os.WIFEXITED(status):
964
+ # The child process exited (e.g sys.exit()).
965
+ return os.WEXITSTATUS(status)
966
+ else:
967
+ # The child exited, but we don't understand its status.
968
+ # This shouldn't happen, but if it does, let's just
969
+ # return that status; perhaps that helps debug it.
970
+ return status
971
+
972
+
973
+ class BaseChildWatcher(AbstractChildWatcher):
974
+
975
+ def __init__(self):
976
+ self._loop = None
977
+ self._callbacks = {}
978
+
979
+ def close(self):
980
+ self.attach_loop(None)
981
+
982
+ def is_active(self):
983
+ return self._loop is not None and self._loop.is_running()
984
+
985
+ def _do_waitpid(self, expected_pid):
986
+ raise NotImplementedError()
987
+
988
+ def _do_waitpid_all(self):
989
+ raise NotImplementedError()
990
+
991
+ def attach_loop(self, loop):
992
+ assert loop is None or isinstance(loop, events.AbstractEventLoop)
993
+
994
+ if self._loop is not None and loop is None and self._callbacks:
995
+ warnings.warn(
996
+ 'A loop is being detached '
997
+ 'from a child watcher with pending handlers',
998
+ RuntimeWarning)
999
+
1000
+ if self._loop is not None:
1001
+ self._loop.remove_signal_handler(signal.SIGCHLD)
1002
+
1003
+ self._loop = loop
1004
+ if loop is not None:
1005
+ loop.add_signal_handler(signal.SIGCHLD, self._sig_chld)
1006
+
1007
+ # Prevent a race condition in case a child terminated
1008
+ # during the switch.
1009
+ self._do_waitpid_all()
1010
+
1011
+ def _sig_chld(self):
1012
+ try:
1013
+ self._do_waitpid_all()
1014
+ except (SystemExit, KeyboardInterrupt):
1015
+ raise
1016
+ except BaseException as exc:
1017
+ # self._loop should always be available here
1018
+ # as '_sig_chld' is added as a signal handler
1019
+ # in 'attach_loop'
1020
+ self._loop.call_exception_handler({
1021
+ 'message': 'Unknown exception in SIGCHLD handler',
1022
+ 'exception': exc,
1023
+ })
1024
+
1025
+
1026
+ class SafeChildWatcher(BaseChildWatcher):
1027
+ """'Safe' child watcher implementation.
1028
+
1029
+ This implementation avoids disrupting other code spawning processes by
1030
+ polling explicitly each process in the SIGCHLD handler instead of calling
1031
+ os.waitpid(-1).
1032
+
1033
+ This is a safe solution but it has a significant overhead when handling a
1034
+ big number of children (O(n) each time SIGCHLD is raised)
1035
+ """
1036
+
1037
+ def close(self):
1038
+ self._callbacks.clear()
1039
+ super().close()
1040
+
1041
+ def __enter__(self):
1042
+ return self
1043
+
1044
+ def __exit__(self, a, b, c):
1045
+ pass
1046
+
1047
+ def add_child_handler(self, pid, callback, *args):
1048
+ self._callbacks[pid] = (callback, args)
1049
+
1050
+ # Prevent a race condition in case the child is already terminated.
1051
+ self._do_waitpid(pid)
1052
+
1053
+ def remove_child_handler(self, pid):
1054
+ try:
1055
+ del self._callbacks[pid]
1056
+ return True
1057
+ except KeyError:
1058
+ return False
1059
+
1060
+ def _do_waitpid_all(self):
1061
+
1062
+ for pid in list(self._callbacks):
1063
+ self._do_waitpid(pid)
1064
+
1065
+ def _do_waitpid(self, expected_pid):
1066
+ assert expected_pid > 0
1067
+
1068
+ try:
1069
+ pid, status = os.waitpid(expected_pid, os.WNOHANG)
1070
+ except ChildProcessError:
1071
+ # The child process is already reaped
1072
+ # (may happen if waitpid() is called elsewhere).
1073
+ pid = expected_pid
1074
+ returncode = 255
1075
+ logger.warning(
1076
+ "Unknown child process pid %d, will report returncode 255",
1077
+ pid)
1078
+ else:
1079
+ if pid == 0:
1080
+ # The child process is still alive.
1081
+ return
1082
+
1083
+ returncode = _compute_returncode(status)
1084
+ if self._loop.get_debug():
1085
+ logger.debug('process %s exited with returncode %s',
1086
+ expected_pid, returncode)
1087
+
1088
+ try:
1089
+ callback, args = self._callbacks.pop(pid)
1090
+ except KeyError: # pragma: no cover
1091
+ # May happen if .remove_child_handler() is called
1092
+ # after os.waitpid() returns.
1093
+ if self._loop.get_debug():
1094
+ logger.warning("Child watcher got an unexpected pid: %r",
1095
+ pid, exc_info=True)
1096
+ else:
1097
+ callback(pid, returncode, *args)
1098
+
1099
+
1100
+ class FastChildWatcher(BaseChildWatcher):
1101
+ """'Fast' child watcher implementation.
1102
+
1103
+ This implementation reaps every terminated processes by calling
1104
+ os.waitpid(-1) directly, possibly breaking other code spawning processes
1105
+ and waiting for their termination.
1106
+
1107
+ There is no noticeable overhead when handling a big number of children
1108
+ (O(1) each time a child terminates).
1109
+ """
1110
+ def __init__(self):
1111
+ super().__init__()
1112
+ self._lock = threading.Lock()
1113
+ self._zombies = {}
1114
+ self._forks = 0
1115
+
1116
+ def close(self):
1117
+ self._callbacks.clear()
1118
+ self._zombies.clear()
1119
+ super().close()
1120
+
1121
+ def __enter__(self):
1122
+ with self._lock:
1123
+ self._forks += 1
1124
+
1125
+ return self
1126
+
1127
+ def __exit__(self, a, b, c):
1128
+ with self._lock:
1129
+ self._forks -= 1
1130
+
1131
+ if self._forks or not self._zombies:
1132
+ return
1133
+
1134
+ collateral_victims = str(self._zombies)
1135
+ self._zombies.clear()
1136
+
1137
+ logger.warning(
1138
+ "Caught subprocesses termination from unknown pids: %s",
1139
+ collateral_victims)
1140
+
1141
+ def add_child_handler(self, pid, callback, *args):
1142
+ assert self._forks, "Must use the context manager"
1143
+
1144
+ with self._lock:
1145
+ try:
1146
+ returncode = self._zombies.pop(pid)
1147
+ except KeyError:
1148
+ # The child is running.
1149
+ self._callbacks[pid] = callback, args
1150
+ return
1151
+
1152
+ # The child is dead already. We can fire the callback.
1153
+ callback(pid, returncode, *args)
1154
+
1155
+ def remove_child_handler(self, pid):
1156
+ try:
1157
+ del self._callbacks[pid]
1158
+ return True
1159
+ except KeyError:
1160
+ return False
1161
+
1162
+ def _do_waitpid_all(self):
1163
+ # Because of signal coalescing, we must keep calling waitpid() as
1164
+ # long as we're able to reap a child.
1165
+ while True:
1166
+ try:
1167
+ pid, status = os.waitpid(-1, os.WNOHANG)
1168
+ except ChildProcessError:
1169
+ # No more child processes exist.
1170
+ return
1171
+ else:
1172
+ if pid == 0:
1173
+ # A child process is still alive.
1174
+ return
1175
+
1176
+ returncode = _compute_returncode(status)
1177
+
1178
+ with self._lock:
1179
+ try:
1180
+ callback, args = self._callbacks.pop(pid)
1181
+ except KeyError:
1182
+ # unknown child
1183
+ if self._forks:
1184
+ # It may not be registered yet.
1185
+ self._zombies[pid] = returncode
1186
+ if self._loop.get_debug():
1187
+ logger.debug('unknown process %s exited '
1188
+ 'with returncode %s',
1189
+ pid, returncode)
1190
+ continue
1191
+ callback = None
1192
+ else:
1193
+ if self._loop.get_debug():
1194
+ logger.debug('process %s exited with returncode %s',
1195
+ pid, returncode)
1196
+
1197
+ if callback is None:
1198
+ logger.warning(
1199
+ "Caught subprocess termination from unknown pid: "
1200
+ "%d -> %d", pid, returncode)
1201
+ else:
1202
+ callback(pid, returncode, *args)
1203
+
1204
+
1205
+ class MultiLoopChildWatcher(AbstractChildWatcher):
1206
+ """A watcher that doesn't require running loop in the main thread.
1207
+
1208
+ This implementation registers a SIGCHLD signal handler on
1209
+ instantiation (which may conflict with other code that
1210
+ install own handler for this signal).
1211
+
1212
+ The solution is safe but it has a significant overhead when
1213
+ handling a big number of processes (*O(n)* each time a
1214
+ SIGCHLD is received).
1215
+ """
1216
+
1217
+ # Implementation note:
1218
+ # The class keeps compatibility with AbstractChildWatcher ABC
1219
+ # To achieve this it has empty attach_loop() method
1220
+ # and doesn't accept explicit loop argument
1221
+ # for add_child_handler()/remove_child_handler()
1222
+ # but retrieves the current loop by get_running_loop()
1223
+
1224
+ def __init__(self):
1225
+ self._callbacks = {}
1226
+ self._saved_sighandler = None
1227
+
1228
+ def is_active(self):
1229
+ return self._saved_sighandler is not None
1230
+
1231
+ def close(self):
1232
+ self._callbacks.clear()
1233
+ if self._saved_sighandler is not None:
1234
+ handler = signal.getsignal(signal.SIGCHLD)
1235
+ if handler != self._sig_chld:
1236
+ logger.warning("SIGCHLD handler was changed by outside code")
1237
+ else:
1238
+ signal.signal(signal.SIGCHLD, self._saved_sighandler)
1239
+ self._saved_sighandler = None
1240
+
1241
+ def __enter__(self):
1242
+ return self
1243
+
1244
+ def __exit__(self, exc_type, exc_val, exc_tb):
1245
+ pass
1246
+
1247
+ def add_child_handler(self, pid, callback, *args):
1248
+ loop = events.get_running_loop()
1249
+ self._callbacks[pid] = (loop, callback, args)
1250
+
1251
+ # Prevent a race condition in case the child is already terminated.
1252
+ self._do_waitpid(pid)
1253
+
1254
+ def remove_child_handler(self, pid):
1255
+ try:
1256
+ del self._callbacks[pid]
1257
+ return True
1258
+ except KeyError:
1259
+ return False
1260
+
1261
+ def attach_loop(self, loop):
1262
+ # Don't save the loop but initialize itself if called first time
1263
+ # The reason to do it here is that attach_loop() is called from
1264
+ # unix policy only for the main thread.
1265
+ # Main thread is required for subscription on SIGCHLD signal
1266
+ if self._saved_sighandler is None:
1267
+ self._saved_sighandler = signal.signal(signal.SIGCHLD, self._sig_chld)
1268
+ if self._saved_sighandler is None:
1269
+ logger.warning("Previous SIGCHLD handler was set by non-Python code, "
1270
+ "restore to default handler on watcher close.")
1271
+ self._saved_sighandler = signal.SIG_DFL
1272
+
1273
+ # Set SA_RESTART to limit EINTR occurrences.
1274
+ signal.siginterrupt(signal.SIGCHLD, False)
1275
+
1276
+ def _do_waitpid_all(self):
1277
+ for pid in list(self._callbacks):
1278
+ self._do_waitpid(pid)
1279
+
1280
+ def _do_waitpid(self, expected_pid):
1281
+ assert expected_pid > 0
1282
+
1283
+ try:
1284
+ pid, status = os.waitpid(expected_pid, os.WNOHANG)
1285
+ except ChildProcessError:
1286
+ # The child process is already reaped
1287
+ # (may happen if waitpid() is called elsewhere).
1288
+ pid = expected_pid
1289
+ returncode = 255
1290
+ logger.warning(
1291
+ "Unknown child process pid %d, will report returncode 255",
1292
+ pid)
1293
+ debug_log = False
1294
+ else:
1295
+ if pid == 0:
1296
+ # The child process is still alive.
1297
+ return
1298
+
1299
+ returncode = _compute_returncode(status)
1300
+ debug_log = True
1301
+ try:
1302
+ loop, callback, args = self._callbacks.pop(pid)
1303
+ except KeyError: # pragma: no cover
1304
+ # May happen if .remove_child_handler() is called
1305
+ # after os.waitpid() returns.
1306
+ logger.warning("Child watcher got an unexpected pid: %r",
1307
+ pid, exc_info=True)
1308
+ else:
1309
+ if loop.is_closed():
1310
+ logger.warning("Loop %r that handles pid %r is closed", loop, pid)
1311
+ else:
1312
+ if debug_log and loop.get_debug():
1313
+ logger.debug('process %s exited with returncode %s',
1314
+ expected_pid, returncode)
1315
+ loop.call_soon_threadsafe(callback, pid, returncode, *args)
1316
+
1317
+ def _sig_chld(self, signum, frame):
1318
+ try:
1319
+ self._do_waitpid_all()
1320
+ except (SystemExit, KeyboardInterrupt):
1321
+ raise
1322
+ except BaseException:
1323
+ logger.warning('Unknown exception in SIGCHLD handler', exc_info=True)
1324
+
1325
+
1326
+ class ThreadedChildWatcher(AbstractChildWatcher):
1327
+ """Threaded child watcher implementation.
1328
+
1329
+ The watcher uses a thread per process
1330
+ for waiting for the process finish.
1331
+
1332
+ It doesn't require subscription on POSIX signal
1333
+ but a thread creation is not free.
1334
+
1335
+ The watcher has O(1) complexity, its performance doesn't depend
1336
+ on amount of spawn processes.
1337
+ """
1338
+
1339
+ def __init__(self):
1340
+ self._pid_counter = itertools.count(0)
1341
+ self._threads = {}
1342
+
1343
+ def is_active(self):
1344
+ return True
1345
+
1346
+ def close(self):
1347
+ self._join_threads()
1348
+
1349
+ def _join_threads(self):
1350
+ """Internal: Join all non-daemon threads"""
1351
+ threads = [thread for thread in list(self._threads.values())
1352
+ if thread.is_alive() and not thread.daemon]
1353
+ for thread in threads:
1354
+ thread.join()
1355
+
1356
+ def __enter__(self):
1357
+ return self
1358
+
1359
+ def __exit__(self, exc_type, exc_val, exc_tb):
1360
+ pass
1361
+
1362
+ def __del__(self, _warn=warnings.warn):
1363
+ threads = [thread for thread in list(self._threads.values())
1364
+ if thread.is_alive()]
1365
+ if threads:
1366
+ _warn(f"{self.__class__} has registered but not finished child processes",
1367
+ ResourceWarning,
1368
+ source=self)
1369
+
1370
+ def add_child_handler(self, pid, callback, *args):
1371
+ loop = events.get_running_loop()
1372
+ thread = threading.Thread(target=self._do_waitpid,
1373
+ name=f"waitpid-{next(self._pid_counter)}",
1374
+ args=(loop, pid, callback, args),
1375
+ daemon=True)
1376
+ self._threads[pid] = thread
1377
+ thread.start()
1378
+
1379
+ def remove_child_handler(self, pid):
1380
+ # asyncio never calls remove_child_handler() !!!
1381
+ # The method is no-op but is implemented because
1382
+ # abstract base classe requires it
1383
+ return True
1384
+
1385
+ def attach_loop(self, loop):
1386
+ pass
1387
+
1388
+ def _do_waitpid(self, loop, expected_pid, callback, args):
1389
+ assert expected_pid > 0
1390
+
1391
+ try:
1392
+ pid, status = os.waitpid(expected_pid, 0)
1393
+ except ChildProcessError:
1394
+ # The child process is already reaped
1395
+ # (may happen if waitpid() is called elsewhere).
1396
+ pid = expected_pid
1397
+ returncode = 255
1398
+ logger.warning(
1399
+ "Unknown child process pid %d, will report returncode 255",
1400
+ pid)
1401
+ else:
1402
+ returncode = _compute_returncode(status)
1403
+ if loop.get_debug():
1404
+ logger.debug('process %s exited with returncode %s',
1405
+ expected_pid, returncode)
1406
+
1407
+ if loop.is_closed():
1408
+ logger.warning("Loop %r that handles pid %r is closed", loop, pid)
1409
+ else:
1410
+ loop.call_soon_threadsafe(callback, pid, returncode, *args)
1411
+
1412
+ self._threads.pop(expected_pid)
1413
+
1414
+
1415
+ class _UnixDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
1416
+ """UNIX event loop policy with a watcher for child processes."""
1417
+ _loop_factory = _UnixSelectorEventLoop
1418
+
1419
+ def __init__(self):
1420
+ super().__init__()
1421
+ self._watcher = None
1422
+
1423
+ def _init_watcher(self):
1424
+ with events._lock:
1425
+ if self._watcher is None: # pragma: no branch
1426
+ self._watcher = ThreadedChildWatcher()
1427
+ if threading.current_thread() is threading.main_thread():
1428
+ self._watcher.attach_loop(self._local._loop)
1429
+
1430
+ def set_event_loop(self, loop):
1431
+ """Set the event loop.
1432
+
1433
+ As a side effect, if a child watcher was set before, then calling
1434
+ .set_event_loop() from the main thread will call .attach_loop(loop) on
1435
+ the child watcher.
1436
+ """
1437
+
1438
+ super().set_event_loop(loop)
1439
+
1440
+ if (self._watcher is not None and
1441
+ threading.current_thread() is threading.main_thread()):
1442
+ self._watcher.attach_loop(loop)
1443
+
1444
+ def get_child_watcher(self):
1445
+ """Get the watcher for child processes.
1446
+
1447
+ If not yet set, a ThreadedChildWatcher object is automatically created.
1448
+ """
1449
+ if self._watcher is None:
1450
+ self._init_watcher()
1451
+
1452
+ return self._watcher
1453
+
1454
+ def set_child_watcher(self, watcher):
1455
+ """Set the watcher for child processes."""
1456
+
1457
+ assert watcher is None or isinstance(watcher, AbstractChildWatcher)
1458
+
1459
+ if self._watcher is not None:
1460
+ self._watcher.close()
1461
+
1462
+ self._watcher = watcher
1463
+
1464
+
1465
+ SelectorEventLoop = _UnixSelectorEventLoop
1466
+ DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy