Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async support #653

Open
sugizo opened this issue Feb 10, 2021 · 0 comments
Open

async support #653

sugizo opened this issue Feb 10, 2021 · 0 comments

Comments

@sugizo
Copy link

sugizo commented Feb 10, 2021

tested pydal with blacksheep (add async on def function and await on db IO operation), but got an error
exposed/install.py

@app.route('/install', methods = ['GET'] )
async def install(request):
    if db(db.test).isempty():
        test_id_1 = await db.test.insert(name = "test1")
        test_id_1 = await db.test.insert(name = "test2")
    db.commit()
    return responses.redirect('/api/get/test/1')

result

Internal Server Error.
While handling request: GET /install

Exception type:
TypeError
Exception message:
object Reference can't be used in 'await' expression
Stack trace:

Traceback (most recent call last):
  File "blacksheep/baseapp.pyx", line 72, in blacksheep.baseapp.BaseApplication.handle
  File "/Users/sugizo/Downloads/blacksheep_pydal/test/exposed/install.py", line 10, in install
    test_id_1 = await db.test.insert(name = "test1")
TypeError: object Reference can't be used in 'await' expression
Process ID: 1885.

exposed/api.py

@app.route('/api/get/{tablename}/{rec_id}', methods = ['GET'] )
async def get(request, tablename, rec_id):
    query = (db[tablename]['id'] == rec_id)
    rows = await db(query).select().as_json()
    return responses.text(rows)

result

Internal Server Error.
While handling request: GET /api/get/test/1

Exception type:
TypeError
Exception message:
object str can't be used in 'await' expression
Stack trace:

Traceback (most recent call last):
  File "blacksheep/baseapp.pyx", line 72, in blacksheep.baseapp.BaseApplication.handle
  File "/Users/sugizo/miniconda3/envs/python3_test/lib/python3.8/site-packages/blacksheep/server/normalization.py", line 438, in handler
    return await method(*values)
  File "/Users/sugizo/Downloads/blacksheep_pydal/test/exposed/api.py", line 18, in get
    rows = await db(query).select().as_json()
TypeError: object str can't be used in 'await' expression
Process ID: 1916.

seems pydal not support async at the moment
it'll nice to have pydal support async

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant