Skip to content

Commit 364896d

Browse files
committed
adding dev-v0.16.2 tag to this commit to ensure building
1 parent 2a5df36 commit 364896d

File tree

6 files changed

+283
-167
lines changed

6 files changed

+283
-167
lines changed

html/supertokens_python/async_to_sync_wrapper.html

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,34 @@ <h1 class="title">Module <code>supertokens_python.async_to_sync_wrapper</code></
4242

4343
import asyncio
4444
from typing import Any, Coroutine, TypeVar
45+
from os import getenv
4546

4647
_T = TypeVar(&#34;_T&#34;)
4748

4849

49-
def check_event_loop():
50+
def nest_asyncio_enabled():
51+
return getenv(&#34;SUPERTOKENS_NEST_ASYNCIO&#34;, &#34;&#34;) == &#34;1&#34;
52+
53+
54+
def create_or_get_event_loop() -&gt; asyncio.AbstractEventLoop:
5055
try:
51-
asyncio.get_event_loop()
52-
except RuntimeError as ex:
56+
return asyncio.get_event_loop()
57+
except Exception as ex:
5358
if &#34;There is no current event loop in thread&#34; in str(ex):
5459
loop = asyncio.new_event_loop()
60+
61+
if nest_asyncio_enabled():
62+
import nest_asyncio # type: ignore
63+
64+
nest_asyncio.apply(loop) # type: ignore
65+
5566
asyncio.set_event_loop(loop)
67+
return loop
68+
raise ex
5669

5770

5871
def sync(co: Coroutine[Any, Any, _T]) -&gt; _T:
59-
check_event_loop()
60-
loop = asyncio.get_event_loop()
72+
loop = create_or_get_event_loop()
6173
return loop.run_until_complete(co)</code></pre>
6274
</details>
6375
</section>
@@ -68,22 +80,43 @@ <h1 class="title">Module <code>supertokens_python.async_to_sync_wrapper</code></
6880
<section>
6981
<h2 class="section-title" id="header-functions">Functions</h2>
7082
<dl>
71-
<dt id="supertokens_python.async_to_sync_wrapper.check_event_loop"><code class="name flex">
72-
<span>def <span class="ident">check_event_loop</span></span>(<span>)</span>
83+
<dt id="supertokens_python.async_to_sync_wrapper.create_or_get_event_loop"><code class="name flex">
84+
<span>def <span class="ident">create_or_get_event_loop</span></span>(<span>)> asyncio.events.AbstractEventLoop</span>
7385
</code></dt>
7486
<dd>
7587
<div class="desc"></div>
7688
<details class="source">
7789
<summary>
7890
<span>Expand source code</span>
7991
</summary>
80-
<pre><code class="python">def check_event_loop():
92+
<pre><code class="python">def create_or_get_event_loop() -&gt; asyncio.AbstractEventLoop:
8193
try:
82-
asyncio.get_event_loop()
83-
except RuntimeError as ex:
94+
return asyncio.get_event_loop()
95+
except Exception as ex:
8496
if &#34;There is no current event loop in thread&#34; in str(ex):
8597
loop = asyncio.new_event_loop()
86-
asyncio.set_event_loop(loop)</code></pre>
98+
99+
if nest_asyncio_enabled():
100+
import nest_asyncio # type: ignore
101+
102+
nest_asyncio.apply(loop) # type: ignore
103+
104+
asyncio.set_event_loop(loop)
105+
return loop
106+
raise ex</code></pre>
107+
</details>
108+
</dd>
109+
<dt id="supertokens_python.async_to_sync_wrapper.nest_asyncio_enabled"><code class="name flex">
110+
<span>def <span class="ident">nest_asyncio_enabled</span></span>(<span>)</span>
111+
</code></dt>
112+
<dd>
113+
<div class="desc"></div>
114+
<details class="source">
115+
<summary>
116+
<span>Expand source code</span>
117+
</summary>
118+
<pre><code class="python">def nest_asyncio_enabled():
119+
return getenv(&#34;SUPERTOKENS_NEST_ASYNCIO&#34;, &#34;&#34;) == &#34;1&#34;</code></pre>
87120
</details>
88121
</dd>
89122
<dt id="supertokens_python.async_to_sync_wrapper.sync"><code class="name flex">
@@ -96,8 +129,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
96129
<span>Expand source code</span>
97130
</summary>
98131
<pre><code class="python">def sync(co: Coroutine[Any, Any, _T]) -&gt; _T:
99-
check_event_loop()
100-
loop = asyncio.get_event_loop()
132+
loop = create_or_get_event_loop()
101133
return loop.run_until_complete(co)</code></pre>
102134
</details>
103135
</dd>
@@ -119,7 +151,8 @@ <h2>Index</h2>
119151
</li>
120152
<li><h3><a href="#header-functions">Functions</a></h3>
121153
<ul class="">
122-
<li><code><a title="supertokens_python.async_to_sync_wrapper.check_event_loop" href="#supertokens_python.async_to_sync_wrapper.check_event_loop">check_event_loop</a></code></li>
154+
<li><code><a title="supertokens_python.async_to_sync_wrapper.create_or_get_event_loop" href="#supertokens_python.async_to_sync_wrapper.create_or_get_event_loop">create_or_get_event_loop</a></code></li>
155+
<li><code><a title="supertokens_python.async_to_sync_wrapper.nest_asyncio_enabled" href="#supertokens_python.async_to_sync_wrapper.nest_asyncio_enabled">nest_asyncio_enabled</a></code></li>
123156
<li><code><a title="supertokens_python.async_to_sync_wrapper.sync" href="#supertokens_python.async_to_sync_wrapper.sync">sync</a></code></li>
124157
</ul>
125158
</li>

html/supertokens_python/constants.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h1 class="title">Module <code>supertokens_python.constants</code></h1>
4242
from __future__ import annotations
4343

4444
SUPPORTED_CDI_VERSIONS = [&#34;3.0&#34;]
45-
VERSION = &#34;0.16.1&#34;
45+
VERSION = &#34;0.16.2&#34;
4646
TELEMETRY = &#34;/telemetry&#34;
4747
USER_COUNT = &#34;/users/count&#34;
4848
USER_DELETE = &#34;/user/remove&#34;

html/supertokens_python/index.html

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ <h1 class="title">Package <code>supertokens_python</code></h1>
4040
# License for the specific language governing permissions and limitations
4141
# under the License.
4242

43-
from typing import Any, Callable, Dict, List, Optional, Union
43+
from typing import Any, Callable, Dict, List, Optional
4444

4545
from typing_extensions import Literal
4646

@@ -60,11 +60,16 @@ <h1 class="title">Package <code>supertokens_python</code></h1>
6060
framework: Literal[&#34;fastapi&#34;, &#34;flask&#34;, &#34;django&#34;],
6161
supertokens_config: SupertokensConfig,
6262
recipe_list: List[Callable[[supertokens.AppInfo], RecipeModule]],
63-
mode: Union[Literal[&#34;asgi&#34;, &#34;wsgi&#34;], None] = None,
64-
telemetry: Union[bool, None] = None,
63+
mode: Optional[Literal[&#34;asgi&#34;, &#34;wsgi&#34;]] = None,
64+
telemetry: Optional[bool] = None,
6565
):
6666
return Supertokens.init(
67-
app_info, framework, supertokens_config, recipe_list, mode, telemetry
67+
app_info,
68+
framework,
69+
supertokens_config,
70+
recipe_list,
71+
mode,
72+
telemetry,
6873
)
6974

7075

@@ -206,11 +211,16 @@ <h2 class="section-title" id="header-functions">Functions</h2>
206211
framework: Literal[&#34;fastapi&#34;, &#34;flask&#34;, &#34;django&#34;],
207212
supertokens_config: SupertokensConfig,
208213
recipe_list: List[Callable[[supertokens.AppInfo], RecipeModule]],
209-
mode: Union[Literal[&#34;asgi&#34;, &#34;wsgi&#34;], None] = None,
210-
telemetry: Union[bool, None] = None,
214+
mode: Optional[Literal[&#34;asgi&#34;, &#34;wsgi&#34;]] = None,
215+
telemetry: Optional[bool] = None,
211216
):
212217
return Supertokens.init(
213-
app_info, framework, supertokens_config, recipe_list, mode, telemetry
218+
app_info,
219+
framework,
220+
supertokens_config,
221+
recipe_list,
222+
mode,
223+
telemetry,
214224
)</code></pre>
215225
</details>
216226
</dd>

0 commit comments

Comments
 (0)