Skip to content

shutdown() from an AsyncClient's handler #1361

Answered by miguelgrinberg
drzraf asked this question in Q&A
Discussion options

You must be logged in to vote

You can't use Timer in an async application, since it is thread based and blocking under async. Try using sleep instead:

    await asyncio.sleep(20)
    await self.sio.shutdown()

Or if you don't want to wait in your handler:

    async def shutdown_in_20():
        await asyncio.sleep(20)
        await self.sio.shutdown()

    self.sio.start_background_task(shutdown_in_20)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@drzraf
Comment options

Answer selected by drzraf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants