Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

last kwarg forJobQueue.run_repeating method #1333

Closed
Labels
@plammens

Description

@plammens

Just asJobQueue.run_repeating takes afirst optional keyword argument, that specifies the first time a job should be run (as adatetime.datetime object, for example), I believe it would be convenient to add alast optional keyword argument that specified, if relevant, the last time a job should be run.

Use cases

I can think of a few use cases, but I'm sure there are more. For example, suppose the bot is part of a game, during which it has to send regular updates (by using aJob). Suppose the game lasts a fixed amount of time, which set prior to its start; say, 1 hour. Then, by specifying thelast keyword argument, the bot programmer could set the "regular updates job" to end when the game ends.

Current alternative

A workaround I have been using is to specify a separaterun_once job that will run theschedule_removal method on the job at the desired time. A better way is to check inside the job's callback, and remove the job from there usingjob.schedule_removal().

In either case, I find these solutions to be, if not cumbersome, inelegant, compared to having a much simpler-to-use and elegant dedicated feature.


A proposed implementation can be found in#1345.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp