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

[Feature Request] Asynchronous/Asyncio support #101

Closed
Shivelight opened this issue Apr 23, 2018 · 9 comments
Closed

[Feature Request] Asynchronous/Asyncio support #101

Shivelight opened this issue Apr 23, 2018 · 9 comments

Comments

@Shivelight
Copy link

Shivelight commented Apr 23, 2018

It would be nice if asynchronous processing natively supported. I think this feature is necessary and reasonably easy to implement without breaking any code or compatibility as we only need to write new API and HTTP client that support async.

If you agree with this or maybe you have a better idea, I would be happy to work on it.

EDIT: I thought I was writing a commit message, here are some sparkles ✨ ✨ ✨

@Shivelight Shivelight changed the title ✨ [Feature Request] Asynchronous/Asyncio support [Feature Request] Asynchronous/Asyncio support Apr 23, 2018
@Shivelight
Copy link
Author

I've made my own, closing this as no high interest in it.

@alfredfrancis
Copy link

@Shivelight can you merge your solution with this

@Shivelight
Copy link
Author

@alfredfrancis I don't think my solution is good to merge with this; it is a duplicate code infused with async-await. I'm not a pro, but in my opinion, a better solution might be architecture change that allows you to use sync and async HTTP client interchangeably. Personally, I like osuapi connectors solution. Whatever the solution is, it's the maintainer decision.

@tokuhirom tokuhirom reopened this Aug 14, 2020
@tokuhirom
Copy link
Member

If we're dropping Python 3.6- support in the next major release, we can support async natively.
python.org document says, python 3.5 will become EOL at 2020-09-13. It's very soon :)

Is it time to support async?

@Shivelight
Copy link
Author

Is it time to support async?

A yes from me, that would be awesome 🎉

@alfredfrancis
Copy link

Is it time to support async?
yes

@uezo
Copy link

uezo commented Sep 2, 2020

I've just released aiolinebot, async api client library - strictly saying, not client library but async client generator from line-bot-sdk.

https://github.com/uezo/aiolinebot

This is a kind of hack, but by this way it's easy to keep up-to-date with the API updates until async is officially supported.(very soon?)

I hope this will be help for you and our community😃

@wasdee
Copy link
Contributor

wasdee commented Mar 3, 2021

I've just released aiolinebot, async api client library - strictly saying, not client library but async client generator from line-bot-sdk.

uezo/aiolinebot

This is a kind of hack, but by this way it's easy to keep up-to-date with the API updates until async is officially supported.(very soon?)

I hope this will be help for you and our community😃

quoting #310

for those who want a quick solution of webhook part pls use

https://github.com/codustry/line-bot-sdk-python/tree/async-support-for-handler

by pip or poetry add git+https://github.com/codustry/line-bot-sdk-python#async-support-for-handler

handler = WebhookHandlerV2(settings.LINE_SECRET)

@router.post("/line")
async def handle_line_webhook(
        request: Request, 
		signature: str = Header(None, alias="X-Line-Signature")
):
    # get request body as text
    body = await request.body()
    body = body.decode()

    # handle webhook body
    try:
        await handler.handle_async(body, signature)
    except InvalidSignatureError as e:
        print(
                "Invalid signature. Please check your channel access token/channel secret."
        )
        raise e

@handler.add(MessageEvent, message=TextMessage)
async def handle_message(event: MessageEvent):
    response_to_magic_word(event)

This comes from a fastapi framework chatbot.

And a plus that https://github.com/uezo/aiolinebot is fully compatible with https://github.com/codustry/line-bot-sdk-python/tree/async-support-for-handler 🥰

tokuhirom added a commit to tokuhirom/line-bot-sdk-python that referenced this issue Sep 30, 2021
@tokuhirom
Copy link
Member

I created new PR #340 to support this feature. If you have any comments on the PR(especially interface), feel free to submit a comment to the PR.

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

No branches or pull requests

6 participants