Skip to content

[Documentation] Provide resources on how to run PTB in general asyncio frameworks #3401

@Bibo-Joshi

Description

@Bibo-Joshi

What kind of feature are you missing? Where do you notice a shortcoming of PTB?

Documentation on how to

  • run multiple PTB bots in the same python process
  • run PTB side-by-side with other asyncio frameworks in the same python process

is currently rather scarse.

Describe the solution you'd like

A section on the "Frequently requested design patterns" or even a standalone wiki page with some tips on these. Importants points are

  • why App.run_{polling, webhook} are not suitable in these cases
  • Detailing which order to call App.{initialize, start, stop, shutdown} & Updater.start_{polling, webhook} in
  • noting that cancelling pending tasks should be done after the app has shut down (see first bullet point in [BUG] Application gets stuck while manually stopping in async environment #3397 (comment))
  • Some notes along the lines "there are many different design patterns for long-running asyncio processes, and there is probably not one right way for your use case"

Describe alternatives you've considered

No response

Additional context

  • we already have the Tip: thingies in the docstrings of App.run_{polling, webhook}, but that's apparently not enough
  • customwebhookbot showcases this to some extend but the "keep the process alive" part is conveniently covered by uvicorn and Updater is not included
  • There were several threads in the user-group where these topics were touched
  • [BUG] Application gets stuck while manually stopping in async environment #3397

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions