Use nest_asyncio to fix async to sync function

This commit is contained in:
Scoder12
2020-08-05 15:48:37 -07:00
parent 2133d52354
commit ab79581905
3 changed files with 16 additions and 1 deletions
Generated
+13 -1
View File
@@ -395,6 +395,14 @@ optional = false
python-versions = ">=3.5"
version = "4.7.6"
[[package]]
category = "main"
description = "Patch asyncio to allow nested event loops"
name = "nest-asyncio"
optional = false
python-versions = ">=3.5"
version = "1.4.0"
[[package]]
category = "dev"
description = "Core utilities for Python packages"
@@ -744,7 +752,7 @@ idna = ">=2.0"
multidict = ">=4.0"
[metadata]
content-hash = "4044c6cf55441e98661abd6202db3abad444c2e338ab732a4dbc38514a2031b6"
content-hash = "c92c18a07248bbd0df18fba9327c2387af07b06a9a489123e3276810fb4e89fc"
python-versions = "^3.8"
[metadata.files]
@@ -945,6 +953,10 @@ multidict = [
{file = "multidict-4.7.6-cp38-cp38-win_amd64.whl", hash = "sha256:7388d2ef3c55a8ba80da62ecfafa06a1c097c18032a501ffd4cabbc52d7f2b19"},
{file = "multidict-4.7.6.tar.gz", hash = "sha256:fbb77a75e529021e7c4a8d4e823d88ef4d23674a202be4f5addffc72cbb91430"},
]
nest-asyncio = [
{file = "nest_asyncio-1.4.0-py3-none-any.whl", hash = "sha256:ea51120725212ef02e5870dd77fc67ba7343fc945e3b9a7ff93384436e043b6a"},
{file = "nest_asyncio-1.4.0.tar.gz", hash = "sha256:5773054bbc14579b000236f85bc01ecced7ffd045ec8ca4a9809371ec65a59c8"},
]
packaging = [
{file = "packaging-20.4-py2.py3-none-any.whl", hash = "sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181"},
{file = "packaging-20.4.tar.gz", hash = "sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8"},
+1
View File
@@ -16,6 +16,7 @@ flask = "^1.1.2"
werkzeug = "^1.0.1"
asks = "^2.4.8"
aiohttp = "^3.6.2"
nest_asyncio = "^1.4.0"
[tool.poetry.dev-dependencies]
flake8 = "^3.8.3"
+2
View File
@@ -7,6 +7,7 @@ from sys import stderr
from typing import Any, Callable, Dict, Tuple, Union
import aiohttp
import nest_asyncio
JSON_TYPE = Union[str, int, float, bool, type(None), dict, list]
@@ -380,6 +381,7 @@ class ReplitDb(AsyncReplitDb):
values = _async2sync(AsyncReplitDb.values)
nest_asyncio.apply()
db_url = os.environ.get("REPLIT_DB_URL")
if db_url:
db = ReplitDb(db_url)