omlish 0.0.0.dev5__tar.gz → 0.0.0.dev7__tar.gz

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.

Potentially problematic release.


This version of omlish might be problematic. Click here for more details.

Files changed (304) hide show
  1. omlish-0.0.0.dev7/MANIFEST.in +1 -0
  2. omlish-0.0.0.dev7/PKG-INFO +49 -0
  3. omlish-0.0.0.dev7/README.rst +1 -0
  4. omlish-0.0.0.dev7/omlish/__about__.py +110 -0
  5. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/asyncs/__init__.py +9 -9
  6. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/asyncs/anyio.py +123 -19
  7. omlish-0.0.0.dev7/omlish/asyncs/asyncio.py +42 -0
  8. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/asyncs/asyncs.py +9 -6
  9. omlish-0.0.0.dev7/omlish/asyncs/bridge.py +316 -0
  10. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/asyncs/trio_asyncio.py +7 -3
  11. omlish-0.0.0.dev7/omlish/bootstrap.py +737 -0
  12. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/check.py +1 -1
  13. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/__init__.py +5 -0
  14. omlish-0.0.0.dev7/omlish/collections/exceptions.py +2 -0
  15. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/identity.py +7 -0
  16. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/utils.py +38 -9
  17. omlish-0.0.0.dev7/omlish/configs/strings.py +96 -0
  18. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/__init__.py +16 -0
  19. omlish-0.0.0.dev7/omlish/dataclasses/impl/copy.py +30 -0
  20. omlish-0.0.0.dev7/omlish/dataclasses/impl/descriptors.py +95 -0
  21. omlish-0.0.0.dev7/omlish/dataclasses/impl/exceptions.py +8 -0
  22. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/fields.py +24 -25
  23. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/init.py +4 -2
  24. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/main.py +2 -0
  25. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/reflect.py +1 -1
  26. omlish-0.0.0.dev7/omlish/dataclasses/utils.py +67 -0
  27. {omlish-0.0.0.dev5/omlish/lang → omlish-0.0.0.dev7/omlish}/datetimes.py +8 -4
  28. omlish-0.0.0.dev7/omlish/diag/__init__.py +4 -0
  29. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/diag/procfs.py +2 -2
  30. {omlish-0.0.0.dev5/omlish/testing → omlish-0.0.0.dev7/omlish/diag}/pydevd.py +35 -0
  31. omlish-0.0.0.dev7/omlish/diag/threads.py +169 -0
  32. omlish-0.0.0.dev7/omlish/dispatch/_dispatch2.py +65 -0
  33. omlish-0.0.0.dev7/omlish/dispatch/_dispatch3.py +104 -0
  34. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/docker.py +16 -1
  35. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/fnpairs.py +11 -4
  36. {omlish-0.0.0.dev5/omlish/configs → omlish-0.0.0.dev7/omlish/formats}/dotenv.py +15 -24
  37. {omlish-0.0.0.dev5/omlish → omlish-0.0.0.dev7/omlish/formats}/json.py +2 -1
  38. omlish-0.0.0.dev7/omlish/formats/yaml.py +223 -0
  39. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/graphs/trees.py +1 -1
  40. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/http/asgi.py +2 -1
  41. omlish-0.0.0.dev7/omlish/http/collections.py +15 -0
  42. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/http/consts.py +22 -1
  43. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/http/sessions.py +10 -3
  44. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/__init__.py +49 -17
  45. omlish-0.0.0.dev7/omlish/inject/binder.py +192 -0
  46. omlish-0.0.0.dev7/omlish/inject/bindings.py +16 -0
  47. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/eagers.py +2 -8
  48. omlish-0.0.0.dev7/omlish/inject/elements.py +64 -0
  49. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/exceptions.py +1 -1
  50. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/impl/elements.py +37 -12
  51. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/impl/injector.py +72 -25
  52. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/impl/inspect.py +33 -5
  53. omlish-0.0.0.dev7/omlish/inject/impl/origins.py +77 -0
  54. omlish-0.0.0.dev5/omlish/inject/impl/private.py → omlish-0.0.0.dev7/omlish/inject/impl/privates.py +2 -2
  55. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/impl/scopes.py +6 -2
  56. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/injector.py +8 -4
  57. omlish-0.0.0.dev7/omlish/inject/inspect.py +32 -0
  58. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/keys.py +8 -14
  59. omlish-0.0.0.dev7/omlish/inject/listeners.py +26 -0
  60. omlish-0.0.0.dev7/omlish/inject/managed.py +90 -0
  61. omlish-0.0.0.dev7/omlish/inject/multis.py +120 -0
  62. omlish-0.0.0.dev7/omlish/inject/origins.py +30 -0
  63. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/overrides.py +5 -4
  64. omlish-0.0.0.dev5/omlish/inject/private.py → omlish-0.0.0.dev7/omlish/inject/privates.py +6 -10
  65. omlish-0.0.0.dev7/omlish/inject/providers.py +38 -0
  66. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/scopes.py +13 -6
  67. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/types.py +3 -1
  68. omlish-0.0.0.dev7/omlish/inject/utils.py +18 -0
  69. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/iterators.py +69 -2
  70. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/__init__.py +24 -9
  71. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/cached.py +2 -2
  72. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/classes/restrict.py +12 -1
  73. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/classes/simple.py +18 -8
  74. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/contextmanagers.py +13 -4
  75. omlish-0.0.0.dev7/omlish/lang/descriptors.py +228 -0
  76. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/functions.py +8 -28
  77. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/imports.py +67 -0
  78. omlish-0.0.0.dev7/omlish/lang/iterables.py +113 -0
  79. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/maybes.py +3 -0
  80. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/objects.py +38 -0
  81. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/strings.py +25 -0
  82. omlish-0.0.0.dev7/omlish/lang/sys.py +16 -0
  83. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/typing.py +42 -0
  84. omlish-0.0.0.dev7/omlish/lifecycles/__init__.py +34 -0
  85. omlish-0.0.0.dev7/omlish/lifecycles/abstract.py +43 -0
  86. omlish-0.0.0.dev7/omlish/lifecycles/base.py +51 -0
  87. omlish-0.0.0.dev7/omlish/lifecycles/contextmanagers.py +74 -0
  88. omlish-0.0.0.dev7/omlish/lifecycles/controller.py +116 -0
  89. omlish-0.0.0.dev7/omlish/lifecycles/manager.py +161 -0
  90. omlish-0.0.0.dev7/omlish/lifecycles/states.py +43 -0
  91. omlish-0.0.0.dev7/omlish/lifecycles/transitions.py +64 -0
  92. omlish-0.0.0.dev7/omlish/lite/__init__.py +1 -0
  93. omlish-0.0.0.dev7/omlish/lite/cached.py +18 -0
  94. omlish-0.0.0.dev7/omlish/lite/check.py +29 -0
  95. omlish-0.0.0.dev7/omlish/lite/contextmanagers.py +18 -0
  96. omlish-0.0.0.dev7/omlish/lite/json.py +30 -0
  97. omlish-0.0.0.dev7/omlish/lite/logs.py +52 -0
  98. omlish-0.0.0.dev7/omlish/lite/marshal.py +316 -0
  99. omlish-0.0.0.dev7/omlish/lite/reflect.py +49 -0
  100. omlish-0.0.0.dev7/omlish/lite/runtime.py +18 -0
  101. omlish-0.0.0.dev7/omlish/lite/secrets.py +19 -0
  102. omlish-0.0.0.dev7/omlish/lite/strings.py +25 -0
  103. omlish-0.0.0.dev7/omlish/lite/subprocesses.py +112 -0
  104. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/logs/configs.py +15 -2
  105. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/logs/formatters.py +7 -2
  106. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/__init__.py +32 -0
  107. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/any.py +5 -5
  108. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/base.py +27 -11
  109. omlish-0.0.0.dev7/omlish/marshal/base64.py +40 -0
  110. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/dataclasses.py +34 -28
  111. omlish-0.0.0.dev7/omlish/marshal/datetimes.py +146 -0
  112. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/enums.py +14 -8
  113. omlish-0.0.0.dev7/omlish/marshal/exceptions.py +17 -0
  114. omlish-0.0.0.dev7/omlish/marshal/factories.py +114 -0
  115. omlish-0.0.0.dev7/omlish/marshal/forbidden.py +35 -0
  116. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/global_.py +11 -4
  117. omlish-0.0.0.dev7/omlish/marshal/iterables.py +54 -0
  118. omlish-0.0.0.dev7/omlish/marshal/mappings.py +63 -0
  119. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/naming.py +4 -0
  120. omlish-0.0.0.dev7/omlish/marshal/numbers.py +51 -0
  121. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/objects.py +1 -0
  122. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/optionals.py +11 -12
  123. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/polymorphism.py +86 -21
  124. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/primitives.py +4 -5
  125. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/standard.py +13 -8
  126. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/uuids.py +4 -5
  127. omlish-0.0.0.dev7/omlish/matchfns.py +218 -0
  128. omlish-0.0.0.dev7/omlish/os.py +105 -0
  129. omlish-0.0.0.dev7/omlish/reflect/__init__.py +39 -0
  130. omlish-0.0.0.dev7/omlish/reflect/isinstance.py +38 -0
  131. omlish-0.0.0.dev7/omlish/reflect/ops.py +84 -0
  132. omlish-0.0.0.dev7/omlish/reflect/subst.py +110 -0
  133. omlish-0.0.0.dev7/omlish/reflect/types.py +275 -0
  134. omlish-0.0.0.dev7/omlish/secrets/__init__.py +23 -0
  135. omlish-0.0.0.dev7/omlish/secrets/crypto.py +132 -0
  136. omlish-0.0.0.dev7/omlish/secrets/marshal.py +70 -0
  137. omlish-0.0.0.dev7/omlish/secrets/openssl.py +207 -0
  138. omlish-0.0.0.dev7/omlish/secrets/passwords.py +120 -0
  139. omlish-0.0.0.dev7/omlish/secrets/secrets.py +299 -0
  140. omlish-0.0.0.dev7/omlish/secrets/subprocesses.py +42 -0
  141. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/sql/dbs.py +7 -6
  142. omlish-0.0.0.dev7/omlish/sql/duckdb.py +136 -0
  143. omlish-0.0.0.dev7/omlish/sql/exprs.py +12 -0
  144. omlish-0.0.0.dev7/omlish/sql/secrets.py +10 -0
  145. omlish-0.0.0.dev7/omlish/sql/sqlean.py +17 -0
  146. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/term.py +2 -2
  147. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/__init__.py +3 -2
  148. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/inject/harness.py +3 -3
  149. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/marks.py +4 -7
  150. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/plugins/__init__.py +1 -0
  151. omlish-0.0.0.dev7/omlish/testing/pytest/plugins/asyncs.py +136 -0
  152. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/plugins/pydevd.py +1 -1
  153. omlish-0.0.0.dev7/omlish/testing/pytest/plugins/switches.py +105 -0
  154. omlish-0.0.0.dev7/omlish/text/__init__.py +0 -0
  155. omlish-0.0.0.dev7/omlish/text/glyphsplit.py +97 -0
  156. omlish-0.0.0.dev7/omlish.egg-info/PKG-INFO +49 -0
  157. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish.egg-info/SOURCES.txt +66 -10
  158. omlish-0.0.0.dev7/omlish.egg-info/requires.txt +54 -0
  159. omlish-0.0.0.dev7/pyproject.toml +82 -0
  160. omlish-0.0.0.dev5/MANIFEST.in +0 -1
  161. omlish-0.0.0.dev5/PKG-INFO +0 -33
  162. omlish-0.0.0.dev5/README.md +0 -1
  163. omlish-0.0.0.dev5/omlish/__about__.py +0 -6
  164. omlish-0.0.0.dev5/omlish/__init__.py +0 -8
  165. omlish-0.0.0.dev5/omlish/asyncs/asyncio.py +0 -19
  166. omlish-0.0.0.dev5/omlish/dataclasses/impl/exceptions.py +0 -2
  167. omlish-0.0.0.dev5/omlish/diag/threads.py +0 -86
  168. omlish-0.0.0.dev5/omlish/inject/binder.py +0 -12
  169. omlish-0.0.0.dev5/omlish/inject/bindings.py +0 -49
  170. omlish-0.0.0.dev5/omlish/inject/elements.py +0 -43
  171. omlish-0.0.0.dev5/omlish/inject/inspect.py +0 -14
  172. omlish-0.0.0.dev5/omlish/inject/managed.py +0 -24
  173. omlish-0.0.0.dev5/omlish/inject/multis.py +0 -70
  174. omlish-0.0.0.dev5/omlish/inject/providers.py +0 -111
  175. omlish-0.0.0.dev5/omlish/lang/descriptors.py +0 -97
  176. omlish-0.0.0.dev5/omlish/lang/iterables.py +0 -54
  177. omlish-0.0.0.dev5/omlish/lang/sys.py +0 -7
  178. omlish-0.0.0.dev5/omlish/marshal/base64.py +0 -25
  179. omlish-0.0.0.dev5/omlish/marshal/datetimes.py +0 -90
  180. omlish-0.0.0.dev5/omlish/marshal/exceptions.py +0 -7
  181. omlish-0.0.0.dev5/omlish/marshal/factories.py +0 -129
  182. omlish-0.0.0.dev5/omlish/marshal/iterables.py +0 -57
  183. omlish-0.0.0.dev5/omlish/marshal/mappings.py +0 -66
  184. omlish-0.0.0.dev5/omlish/os.py +0 -41
  185. omlish-0.0.0.dev5/omlish/reflect.py +0 -355
  186. omlish-0.0.0.dev5/omlish/testing/pytest/plugins/switches.py +0 -70
  187. omlish-0.0.0.dev5/omlish.egg-info/PKG-INFO +0 -33
  188. omlish-0.0.0.dev5/omlish.egg-info/requires.txt +0 -28
  189. omlish-0.0.0.dev5/pyproject.toml +0 -289
  190. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/LICENSE +0 -0
  191. {omlish-0.0.0.dev5/omlish/diag → omlish-0.0.0.dev7/omlish}/__init__.py +0 -0
  192. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/argparse.py +0 -0
  193. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/asyncs/flavors.py +0 -0
  194. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/asyncs/trio.py +0 -0
  195. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/c3.py +0 -0
  196. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/cached.py +0 -0
  197. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/_abc.py +0 -0
  198. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/_io_abc.py +0 -0
  199. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/cache/__init__.py +0 -0
  200. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/cache/descriptor.py +0 -0
  201. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/cache/impl.py +0 -0
  202. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/cache/types.py +0 -0
  203. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/coerce.py +0 -0
  204. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/frozen.py +0 -0
  205. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/indexed.py +0 -0
  206. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/mappings.py +0 -0
  207. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/ordered.py +0 -0
  208. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/persistent.py +0 -0
  209. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/skiplist.py +0 -0
  210. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/sorted.py +0 -0
  211. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/treap.py +0 -0
  212. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/treapmap.py +0 -0
  213. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/collections/unmodifiable.py +0 -0
  214. /omlish-0.0.0.dev5/omlish/asyncs/futures.py → /omlish-0.0.0.dev7/omlish/concurrent.py +0 -0
  215. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/configs/__init__.py +0 -0
  216. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/configs/classes.py +0 -0
  217. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/configs/flattening.py +0 -0
  218. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/__init__.py +0 -0
  219. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/api.py +0 -0
  220. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/as_.py +0 -0
  221. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/frozen.py +0 -0
  222. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/hashing.py +0 -0
  223. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/internals.py +0 -0
  224. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/metaclass.py +0 -0
  225. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/metadata.py +0 -0
  226. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/order.py +0 -0
  227. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/params.py +0 -0
  228. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/processing.py +0 -0
  229. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/replace.py +0 -0
  230. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/repr.py +0 -0
  231. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/simple.py +0 -0
  232. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/slots.py +0 -0
  233. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dataclasses/impl/utils.py +0 -0
  234. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/defs.py +0 -0
  235. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/diag/procstats.py +0 -0
  236. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/diag/ps.py +0 -0
  237. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/diag/replserver/__init__.py +0 -0
  238. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/diag/replserver/__main__.py +0 -0
  239. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/diag/replserver/console.py +0 -0
  240. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/diag/replserver/server.py +0 -0
  241. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dispatch/__init__.py +0 -0
  242. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dispatch/dispatch.py +0 -0
  243. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dispatch/functions.py +0 -0
  244. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dispatch/methods.py +0 -0
  245. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/dynamic.py +0 -0
  246. {omlish-0.0.0.dev5/omlish/graphs → omlish-0.0.0.dev7/omlish/formats}/__init__.py +0 -0
  247. {omlish-0.0.0.dev5/omlish/configs → omlish-0.0.0.dev7/omlish/formats}/props.py +0 -0
  248. {omlish-0.0.0.dev5/omlish/inject/impl → omlish-0.0.0.dev7/omlish/graphs}/__init__.py +0 -0
  249. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/graphs/dags.py +0 -0
  250. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/graphs/domination.py +0 -0
  251. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/graphs/dot/__init__.py +0 -0
  252. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/graphs/dot/items.py +0 -0
  253. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/graphs/dot/rendering.py +0 -0
  254. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/graphs/dot/utils.py +0 -0
  255. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/http/__init__.py +0 -0
  256. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/http/cookies.py +0 -0
  257. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/http/dates.py +0 -0
  258. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/http/encodings.py +0 -0
  259. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/http/json.py +0 -0
  260. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/http/wsgi.py +0 -0
  261. {omlish-0.0.0.dev5/omlish/text → omlish-0.0.0.dev7/omlish/inject/impl}/__init__.py +0 -0
  262. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/impl/bindings.py +0 -0
  263. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/impl/multis.py +0 -0
  264. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/impl/providers.py +0 -0
  265. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/inject/impl/proxy.py +0 -0
  266. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/classes/__init__.py +0 -0
  267. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/classes/abstract.py +0 -0
  268. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/classes/virtual.py +0 -0
  269. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/clsdct.py +0 -0
  270. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/cmp.py +0 -0
  271. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/exceptions.py +0 -0
  272. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/resolving.py +0 -0
  273. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/lang/timeouts.py +0 -0
  274. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/libc.py +0 -0
  275. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/logs/__init__.py +0 -0
  276. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/logs/_abc.py +0 -0
  277. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/logs/filters.py +0 -0
  278. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/logs/utils.py +0 -0
  279. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/registries.py +0 -0
  280. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/utils.py +0 -0
  281. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/marshal/values.py +0 -0
  282. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/math.py +0 -0
  283. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/runmodule.py +0 -0
  284. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/sql/__init__.py +0 -0
  285. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/sql/_abc.py +0 -0
  286. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/sql/asyncs.py +0 -0
  287. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/stats.py +0 -0
  288. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/sync.py +0 -0
  289. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/__init__.py +0 -0
  290. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/helpers.py +0 -0
  291. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/inject/__init__.py +0 -0
  292. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/plugins/_registry.py +0 -0
  293. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/plugins/logging.py +0 -0
  294. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/plugins/managermarks.py +0 -0
  295. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/plugins/repeat.py +0 -0
  296. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/plugins/skips.py +0 -0
  297. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/pytest/plugins/spacing.py +0 -0
  298. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/testing/testing.py +0 -0
  299. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/text/delimit.py +0 -0
  300. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/text/indent.py +0 -0
  301. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish/text/parts.py +0 -0
  302. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish.egg-info/dependency_links.txt +0 -0
  303. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/omlish.egg-info/top_level.txt +0 -0
  304. {omlish-0.0.0.dev5 → omlish-0.0.0.dev7}/setup.cfg +0 -0
@@ -0,0 +1 @@
1
+ global-exclude **/conftest.py
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.1
2
+ Name: omlish
3
+ Version: 0.0.0.dev7
4
+ Summary: omlish
5
+ Author: wrmsr
6
+ License: BSD-3-Clause
7
+ Project-URL: source, https://github.com/wrmsr/omlish
8
+ Classifier: License :: OSI Approved :: BSD License
9
+ Classifier: Development Status :: 2 - Pre-Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Operating System :: POSIX
13
+ Requires-Python: >=3.12
14
+ License-File: LICENSE
15
+ Provides-Extra: async
16
+ Requires-Dist: anyio>=4.4; extra == "async"
17
+ Requires-Dist: sniffio>=1.3; extra == "async"
18
+ Requires-Dist: greenlet>=3; python_version < "3.13" and extra == "async"
19
+ Requires-Dist: trio>=0.26; extra == "async"
20
+ Requires-Dist: trio-asyncio>=0.15; python_version < "3.13" and extra == "async"
21
+ Provides-Extra: compression
22
+ Requires-Dist: lz4>=4; extra == "compression"
23
+ Requires-Dist: python-snappy>=0.7; python_version < "3.13" and extra == "compression"
24
+ Requires-Dist: zstd>=1.5; extra == "compression"
25
+ Provides-Extra: formats
26
+ Requires-Dist: orjson>3.10; extra == "formats"
27
+ Requires-Dist: cloudpickle>=3; extra == "formats"
28
+ Requires-Dist: pyyaml>=5; extra == "formats"
29
+ Provides-Extra: http
30
+ Requires-Dist: httpx[http2]>=0.27; extra == "http"
31
+ Provides-Extra: misc
32
+ Requires-Dist: jinja2>=3.1; extra == "misc"
33
+ Requires-Dist: psutil>=6; extra == "misc"
34
+ Requires-Dist: wrapt>=1.14; extra == "misc"
35
+ Provides-Extra: secrets
36
+ Requires-Dist: cryptography>=43; extra == "secrets"
37
+ Provides-Extra: sql
38
+ Requires-Dist: sqlalchemy>=2; python_version >= "3.13" and extra == "sql"
39
+ Requires-Dist: sqlalchemy[asyncio]>=2; python_version < "3.13" and extra == "sql"
40
+ Requires-Dist: pg8000>=1.31; extra == "sql"
41
+ Requires-Dist: pymysql>=1.1; extra == "sql"
42
+ Requires-Dist: aiomysql>=0.2; extra == "sql"
43
+ Requires-Dist: aiosqlite>=0.20; extra == "sql"
44
+ Requires-Dist: asyncpg>=0.29; python_version < "3.13" and extra == "sql"
45
+ Provides-Extra: sqlx
46
+ Requires-Dist: sqlean.py>=3.45; python_version < "3.13" and extra == "sqlx"
47
+ Requires-Dist: duckdb>=1; extra == "sqlx"
48
+ Provides-Extra: testing
49
+ Requires-Dist: pytest>=8; extra == "testing"
@@ -0,0 +1 @@
1
+ *omlish*
@@ -0,0 +1,110 @@
1
+ __version__ = '0.0.0.dev7'
2
+
3
+
4
+ #
5
+
6
+
7
+ class ProjectBase:
8
+ name: str | None = None
9
+ authors = [{'name': 'wrmsr'}]
10
+ urls = {'source': 'https://github.com/wrmsr/omlish'}
11
+ license = {'text': 'BSD-3-Clause'}
12
+ requires_python = '>=3.12'
13
+
14
+ version = __version__
15
+
16
+ classifiers = [
17
+ 'License :: OSI Approved :: BSD License',
18
+ 'Development Status :: 2 - Pre-Alpha',
19
+ 'Intended Audience :: Developers',
20
+
21
+ 'Operating System :: OS Independent',
22
+ 'Operating System :: POSIX',
23
+ ]
24
+
25
+
26
+ class Project(ProjectBase):
27
+ name = 'omlish'
28
+ description = 'omlish'
29
+
30
+ optional_dependencies = {
31
+ 'async': [
32
+ 'anyio >= 4.4',
33
+ 'sniffio >= 1.3',
34
+
35
+ 'greenlet >= 3; python_version < "3.13"',
36
+
37
+ 'trio >= 0.26',
38
+ 'trio-asyncio >= 0.15; python_version < "3.13"',
39
+ ],
40
+
41
+ 'compression': [
42
+ 'lz4 >= 4',
43
+ 'python-snappy >= 0.7; python_version < "3.13"',
44
+ 'zstd >= 1.5',
45
+ ],
46
+
47
+ 'formats': [
48
+ 'orjson > 3.10',
49
+ 'cloudpickle >= 3',
50
+ 'pyyaml >= 5',
51
+ ],
52
+
53
+ 'http': [
54
+ 'httpx[http2] >= 0.27',
55
+ ],
56
+
57
+ 'misc': [
58
+ 'jinja2 >= 3.1',
59
+ 'psutil >= 6',
60
+ 'wrapt >= 1.14',
61
+ ],
62
+
63
+ 'secrets': [
64
+ 'cryptography >= 43',
65
+ ],
66
+
67
+ 'sql': [
68
+ 'sqlalchemy >= 2; python_version >= "3.13"',
69
+ 'sqlalchemy[asyncio] >= 2; python_version < "3.13"',
70
+
71
+ 'pg8000 >= 1.31',
72
+ 'pymysql >= 1.1',
73
+
74
+ 'aiomysql >= 0.2',
75
+ 'aiosqlite >= 0.20',
76
+ 'asyncpg >= 0.29; python_version < "3.13"',
77
+ ],
78
+
79
+ 'sqlx': [
80
+ "sqlean.py >= 3.45; python_version < '3.13'",
81
+
82
+ 'duckdb >= 1',
83
+ ],
84
+
85
+ 'testing': [
86
+ 'pytest >= 8',
87
+ ],
88
+ }
89
+
90
+
91
+ #
92
+
93
+
94
+ class SetuptoolsBase:
95
+ manifest_in = [
96
+ 'global-exclude **/conftest.py',
97
+ ]
98
+
99
+ include_package_data = False
100
+
101
+ find_packages = {
102
+ 'exclude': ['*.tests', '*.tests.*'],
103
+ }
104
+
105
+
106
+ class Setuptools(SetuptoolsBase):
107
+ find_packages = {
108
+ 'include': ['omlish', 'omlish.*'],
109
+ 'exclude': [*SetuptoolsBase.find_packages['exclude']],
110
+ }
@@ -6,6 +6,15 @@ from .asyncs import ( # noqa
6
6
  syncable_iterable,
7
7
  )
8
8
 
9
+ from .bridge import ( # noqa
10
+ a_to_s,
11
+ is_in_bridge,
12
+ s_to_a,
13
+ s_to_a_await,
14
+ trivial_a_to_s,
15
+ trivial_s_to_a,
16
+ )
17
+
9
18
  from .flavors import ( # noqa
10
19
  ContextManagerAdapter,
11
20
  Flavor,
@@ -24,12 +33,3 @@ from .flavors import ( # noqa
24
33
  mark_trio,
25
34
  with_adapter_loop,
26
35
  )
27
-
28
- from .futures import ( # noqa
29
- FutureError,
30
- FutureTimeoutError,
31
- ImmediateExecutor,
32
- new_thread_or_immediate_executor,
33
- wait_dependent_futures,
34
- wait_futures,
35
- )
@@ -13,11 +13,23 @@ lookit:
13
13
  - https://github.com/M-o-a-T/aevent
14
14
  - https://github.com/florimondmanca/aiometer
15
15
  - https://github.com/sanitizers/octomachinery/blob/b36c3d3d49da813ac46e361424132955a4e99ac8/octomachinery/utils/asynctools.py
16
+
17
+ ==
18
+
19
+ async def killer(shutdown: anyio.Event, sleep_s: float) -> None:
20
+ log.warning('Killing in %d seconds', sleep_s)
21
+ await anyio.sleep(sleep_s)
22
+ log.warning('Killing')
23
+ shutdown.set()
24
+
16
25
  """ # noqa
26
+ import signal
17
27
  import typing as ta
18
28
 
29
+ import anyio.abc
19
30
  import anyio.streams.memory
20
31
  import anyio.streams.stapled
32
+ import sniffio
21
33
 
22
34
  from .. import check
23
35
  from .. import lang
@@ -26,6 +38,9 @@ from .. import lang
26
38
  T = ta.TypeVar('T')
27
39
 
28
40
 
41
+ ##
42
+
43
+
29
44
  async def anyio_eof_to_empty(fn: ta.Callable[..., ta.Awaitable[T]], *args: ta.Any, **kwargs: ta.Any) -> T | bytes:
30
45
  try:
31
46
  return await fn(*args, **kwargs)
@@ -33,6 +48,85 @@ async def anyio_eof_to_empty(fn: ta.Callable[..., ta.Awaitable[T]], *args: ta.An
33
48
  return b''
34
49
 
35
50
 
51
+ async def gather(*fns: ta.Callable[..., ta.Awaitable[T]], take_first: bool = False) -> list[lang.Maybe[T]]:
52
+ results: list[lang.Maybe[T]] = [lang.empty()] * len(fns)
53
+
54
+ async def inner(fn, i):
55
+ results[i] = lang.just(await fn())
56
+ if take_first:
57
+ tg.cancel_scope.cancel()
58
+
59
+ async with anyio.create_task_group() as tg:
60
+ for i, fn in enumerate(fns):
61
+ tg.start_soon(inner, fn, i)
62
+
63
+ return results
64
+
65
+
66
+ async def first(*fns: ta.Callable[..., ta.Awaitable[T]], **kwargs: ta.Any) -> list[lang.Maybe[T]]:
67
+ return await gather(*fns, take_first=True, **kwargs)
68
+
69
+
70
+ ##
71
+
72
+
73
+ def get_current_task() -> anyio.TaskInfo | None:
74
+ try:
75
+ return anyio.get_current_task()
76
+ except sniffio.AsyncLibraryNotFoundError:
77
+ return None
78
+
79
+
80
+ #
81
+
82
+
83
+ BackendTask: ta.TypeAlias = ta.Union[ # noqa
84
+ # asyncio.tasks.Task,
85
+ # trio.lowlevel.Task,
86
+ ta.Any,
87
+ ]
88
+
89
+
90
+ def _is_class_named(obj: ta.Any, m: str, n: str) -> bool:
91
+ cls = obj.__class__
92
+ return cls.__module__ == m and cls.__name__ == n
93
+
94
+
95
+ def get_backend_task(at: anyio.TaskInfo) -> BackendTask | None:
96
+ if _is_class_named(at, 'anyio._backends._asyncio', 'AsyncIOTaskInfo'):
97
+ # https://github.com/agronholm/anyio/blob/8907964926a24461840eee0925d3f355e729f15d/src/anyio/_backends/_asyncio.py#L1846 # noqa
98
+ # weakref.ref
99
+ obj = at._task() # type: ignore # noqa
100
+ if obj is not None and not (
101
+ _is_class_named(obj, '_asyncio', 'Task') or
102
+ _is_class_named(obj, 'asyncio.tasks', 'Task')
103
+ ):
104
+ raise TypeError(obj)
105
+ return obj
106
+
107
+ elif _is_class_named(at, 'anyio._backends._trio', 'TrioTaskInfo'):
108
+ # https://github.com/agronholm/anyio/blob/8907964926a24461840eee0925d3f355e729f15d/src/anyio/_backends/_trio.py#L850 # noqa
109
+ # weakref.proxy
110
+ # https://stackoverflow.com/a/62144308 :|
111
+ obj = at._task.__repr__.__self__ # type: ignore # noqa
112
+ if obj is not None and not _is_class_named(obj, 'trio.lowlevel', 'Task'):
113
+ raise TypeError(obj)
114
+ return obj
115
+
116
+ else:
117
+ raise TypeError(at)
118
+
119
+
120
+ def get_current_backend_task() -> BackendTask | None:
121
+ if (at := get_current_task()) is not None:
122
+ return get_backend_task(at)
123
+ else:
124
+ return None
125
+
126
+
127
+ ##
128
+
129
+
36
130
  def split_memory_object_streams(
37
131
  *args: anyio.create_memory_object_stream[T],
38
132
  ) -> tuple[
@@ -72,25 +166,6 @@ def staple_memory_object_stream2[T](max_buffer_size: float = 0) -> anyio.streams
72
166
  )
73
167
 
74
168
 
75
- async def gather(*fns: ta.Callable[..., ta.Awaitable[T]], take_first: bool = False) -> list[lang.Maybe[T]]:
76
- results: list[lang.Maybe[T]] = [lang.empty()] * len(fns)
77
-
78
- async def inner(fn, i):
79
- results[i] = lang.just(await fn())
80
- if take_first:
81
- tg.cancel_scope.cancel()
82
-
83
- async with anyio.create_task_group() as tg:
84
- for i, fn in enumerate(fns):
85
- tg.start_soon(inner, fn, i)
86
-
87
- return results
88
-
89
-
90
- async def first(*fns: ta.Callable[..., ta.Awaitable[T]], **kwargs: ta.Any) -> list[lang.Maybe[T]]:
91
- return await gather(*fns, take_first=True, **kwargs)
92
-
93
-
94
169
  ##
95
170
 
96
171
 
@@ -150,3 +225,32 @@ class LazyFn(ta.Generic[T]):
150
225
  self._v = lang.just(await self._fn())
151
226
  await self._once.do(do)
152
227
  return self._v.must()
228
+
229
+
230
+ ##
231
+
232
+
233
+ async def install_shutdown_signal_handler(
234
+ tg: anyio.abc.TaskGroup,
235
+ event: anyio.Event | None = None,
236
+ *,
237
+ signals: ta.Iterable[int] = (signal.SIGINT, signal.SIGTERM),
238
+ echo: bool = False,
239
+ ) -> ta.Callable[..., ta.Awaitable[None]] | None:
240
+ if event is None:
241
+ event = anyio.Event()
242
+
243
+ async def _handler(*, task_status=anyio.TASK_STATUS_IGNORED):
244
+ with anyio.open_signal_receiver(*signals) as it: # type: ignore
245
+ task_status.started()
246
+ async for signum in it:
247
+ if echo:
248
+ if signum == signal.SIGINT:
249
+ print('Ctrl+C pressed!')
250
+ else:
251
+ print('Terminated!')
252
+ event.set()
253
+ return
254
+
255
+ await tg.start(_handler)
256
+ return event.wait
@@ -0,0 +1,42 @@
1
+ import asyncio
2
+ import contextlib
3
+ import functools
4
+ import typing as ta
5
+
6
+
7
+ CallableT = ta.TypeVar('CallableT', bound=ta.Callable)
8
+
9
+
10
+ def asyncio_once(fn: CallableT) -> CallableT:
11
+ future = None
12
+
13
+ @functools.wraps(fn)
14
+ async def inner(*args, **kwargs):
15
+ nonlocal future
16
+ if not future:
17
+ future = asyncio.create_task(fn(*args, **kwargs))
18
+ return await future
19
+
20
+ return ta.cast(CallableT, inner)
21
+
22
+
23
+ def get_real_current_loop() -> asyncio.AbstractEventLoop | None:
24
+ return asyncio.get_event_loop_policy()._local._loop # type: ignore # noqa
25
+
26
+
27
+ def drain_tasks(loop=None):
28
+ if loop is None:
29
+ loop = get_real_current_loop()
30
+
31
+ while loop._ready or loop._scheduled: # noqa
32
+ loop._run_once() # noqa
33
+
34
+
35
+ @contextlib.contextmanager
36
+ def draining_asyncio_tasks() -> ta.Iterator[None]:
37
+ loop = get_real_current_loop()
38
+ try:
39
+ yield
40
+ finally:
41
+ if loop is not None:
42
+ drain_tasks(loop) # noqa
@@ -5,10 +5,10 @@ TODO:
5
5
  517 ns ± 13.2 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
6
6
  - injected io provider - sync vs greenlet aio trampolined
7
7
  - push/pull bridge?
8
+ - move to lang
8
9
 
9
10
  https://github.com/sqlalchemy/sqlalchemy/blob/1e75c189da721395bc8c2d899c722a5b9a170404/lib/sqlalchemy/util/_concurrency_py3k.py#L83
10
11
  """
11
- import contextlib
12
12
  import functools
13
13
  import typing as ta
14
14
 
@@ -16,8 +16,7 @@ import typing as ta
16
16
  T = ta.TypeVar('T')
17
17
 
18
18
 
19
- def sync_await(fn: ta.Callable[..., T], *args, **kwargs) -> T:
20
- ret: ta.Any
19
+ def sync_await(fn: ta.Callable[..., T], *args: ta.Any, **kwargs: ta.Any) -> T:
21
20
  ret = missing = object()
22
21
 
23
22
  async def gate():
@@ -25,13 +24,17 @@ def sync_await(fn: ta.Callable[..., T], *args, **kwargs) -> T:
25
24
  ret = await fn(*args, **kwargs) # type: ignore
26
25
 
27
26
  cr = gate()
28
- with contextlib.closing(cr):
29
- with contextlib.suppress(StopIteration):
27
+ try:
28
+ try:
30
29
  cr.send(None)
30
+ except StopIteration:
31
+ pass
31
32
  if ret is missing or cr.cr_await is not None or cr.cr_running:
32
33
  raise TypeError('Not terminated')
34
+ finally:
35
+ cr.close()
33
36
 
34
- return ta.cast(T, ret)
37
+ return ret # type: ignore
35
38
 
36
39
 
37
40
  def sync_list(fn: ta.Callable[..., ta.AsyncIterator[T]], *args, **kwargs) -> list[T]: