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

Refactor JobQueue#1981

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Bibo-Joshi merged 19 commits intov13fromrefactor-job-queue
Jul 10, 2020
Merged

Refactor JobQueue#1981

Bibo-Joshi merged 19 commits intov13fromrefactor-job-queue
Jul 10, 2020

Conversation

Bibo-Joshi
Copy link
Member

@Bibo-JoshiBibo-Joshi commentedJun 5, 2020
edited
Loading

When ready,closes#1936 and on the flycloses#2004

Introduces APScheduler as 3rd party lib for scheduling tasts. The PR is not yet really polished, especially I'll need to increase coverage. But before getting started on that, I'd like to get feedback on the general design.

My main concern is theJob (already mentioned offline). Unfortunately, simply subclassingaps.Job to add acontext argument doesn't work - we'd have to patchaps.Job to do that. I don't fancy that.
On the other hand, having a customJob class with custom attributes allows to make switching to another lib a bit less breaking, if we have to do that at some point.
So I added ajob attribute to ourJob class, which holds the correspondingaps.Job.

Besides the fact that rescheduling jobs must now be done directly through theaps interface, the main breaking change is, thatJobQueue now can only handlepytz timezones. But personally, I don't see a problem in that. Switching from fixet utc-offset timezones should be easy enough and people who need weird custom timezones should be capable enough of handling the change …

Reragrding tests:

  • test_official currently fails b/c API 4.9
  • made the timeout tests forConversationHandler a bit more generous on the timing,aps seems to like that
  • switched topytzs everywhere in the tests
  • besides that, I only made the existing tests run. as mentioned above, I'll need to improve coverage, once we're okay with the general design.

EDIT:
That are a lot more failing tests than I'd hoped for … Will need to check on an actual OS locally (yes, I developed on Windows, shame on me …)

EDIT 2:

  • the updater.idle() test just wasn't executed on windows … fixed it.
  • APS is a bit pickier on doing things "right now". That's one of the things, we should mention on the release notes. So I just removedtest_run_repeating_first_immediate andtest_run_repeating_first_timezone is now also adapted for APS' needs

@Bibo-JoshiBibo-Joshi added the 📋 pending-reviewwork status: pending-review labelJun 5, 2020
@Bibo-JoshiBibo-Joshi added this to the13.0 milestoneJun 5, 2020
@Bibo-JoshiBibo-Joshi requested a review fromjh0kerJune 5, 2020 21:28
@Bibo-JoshiBibo-Joshi changed the base branch frommaster tov13June 6, 2020 10:55
@Bibo-JoshiBibo-Joshiforce-pushed thev13 branch 3 times, most recently from45fc55e to2a9a5b0CompareJune 15, 2020 16:24
# Was intended for interal use anyways# Fixes tests
Copy link
Member

@PoolitzerPoolitzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks good to me, I love outsourcing the jobs to the APS.

@@ -742,8 +735,7 @@ def test_conversation_handler_timeout_state_context(self, cdp, bot, user1):
message.text = '/startCoding'
message.entities[0].length = len('/startCoding')
cdp.process_update(Update(update_id=0, message=message))
sleep(0.5)
cdp.job_queue.tick()
sleep(0.6)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

doesnt it make sense to put this in a constant?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not sure, if that's a good idea. Have one of the tests failing in the future, fiddle with the constant, suddenly everthing fails and it's not obvious why …

return self._tz_now() + time
if isinstance(time, datetime.time):
dt = datetime.datetime.combine(datetime.datetime.now().date(), time,
tzinfo=time.tzinfo or self.scheduler.timezone)
Copy link
Member

@jh0kerjh0kerJun 24, 2020
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't know about this... Are we dropping 3.5 support (or did we already)? Thetzinfo argument tocombine has been added in 3.6.

Apart from that, couldn'tdatetime.datetime.now().date() return the wrong date this way?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Uh, you're right. Couldn't tell, because TG messed up our tests again …. But we're dropping py3.5 an#1920 anyway, so we might as well do here.

And right once more. I'll add it back.

@Bibo-JoshiBibo-Joshi removed the 📋 pending-reviewwork status: pending-review labelJul 8, 2020
@Bibo-Joshi
Copy link
MemberAuthor

py3.7 fail unrelated. Codacy can't check for some reason, but I ran pre-commit locally again and it's fine.
As discussed offline we'll probably need to do some clean up after release anyway, but we need people to actaully use the new JobQueue for that. Merging.

@Bibo-JoshiBibo-Joshi merged commit088e608 intov13Jul 10, 2020
@Bibo-JoshiBibo-Joshi deleted the refactor-job-queue branchJuly 10, 2020 11:11
Bibo-Joshi added a commit that referenced this pull requestJul 14, 2020
* First go on refactoring JobQueue* Temporarily enable tests for the v13 branch* Work on tests* Temporarily enable tests for the v13 branch* Increase coverage* Remove JobQueue.tick()# Was intended for interal use anyways# Fixes tests* Address review* Temporarily enable tests for the v13 branch* Address review* Dispatch errors* Fix handling of job_kwargs* Remove possibility to pass a Bot to JobQueue
@Bibo-JoshiBibo-Joshi mentioned this pull requestJul 18, 2020
Bibo-Joshi added a commit that referenced this pull requestJul 19, 2020
* First go on refactoring JobQueue* Temporarily enable tests for the v13 branch* Work on tests* Temporarily enable tests for the v13 branch* Increase coverage* Remove JobQueue.tick()# Was intended for interal use anyways# Fixes tests* Address review* Temporarily enable tests for the v13 branch* Address review* Dispatch errors* Fix handling of job_kwargs* Remove possibility to pass a Bot to JobQueue
Bibo-Joshi added a commit that referenced this pull requestJul 19, 2020
* Refactor handling of `default_quote`* Make it a breaking change* Pickle a bots defaults* Temporarily enable tests for the v13 branch* Temporarily enable tests for the v13 branch* Refactor handling of kwargs in Bot methods (#1924)* Unify kwargs handling in Bot methods* Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class* Fix test_official* Update get_file methods* Refactor JobQueue (#1981)* First go on refactoring JobQueue* Temporarily enable tests for the v13 branch* Work on tests* Temporarily enable tests for the v13 branch* Increase coverage* Remove JobQueue.tick()# Was intended for interal use anyways# Fixes tests* Address review* Temporarily enable tests for the v13 branch* Address review* Dispatch errors* Fix handling of job_kwargs* Remove possibility to pass a Bot to JobQueue* Refactor persistence of Bot instances (#1994)* Refactor persistence of bots* User BP.set_bot in Dispatcher* Temporarily enable tests for the v13 branch* Add documentation* Add warning to Updater for passing both defaults and bot* Address review* Fix test
Bibo-Joshi added a commit that referenced this pull requestAug 13, 2020
* First go on refactoring JobQueue* Temporarily enable tests for the v13 branch* Work on tests* Temporarily enable tests for the v13 branch* Increase coverage* Remove JobQueue.tick()# Was intended for interal use anyways# Fixes tests* Address review* Temporarily enable tests for the v13 branch* Address review* Dispatch errors* Fix handling of job_kwargs* Remove possibility to pass a Bot to JobQueue
Bibo-Joshi added a commit that referenced this pull requestAug 13, 2020
* Refactor handling of `default_quote`* Make it a breaking change* Pickle a bots defaults* Temporarily enable tests for the v13 branch* Temporarily enable tests for the v13 branch* Refactor handling of kwargs in Bot methods (#1924)* Unify kwargs handling in Bot methods* Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class* Fix test_official* Update get_file methods* Refactor JobQueue (#1981)* First go on refactoring JobQueue* Temporarily enable tests for the v13 branch* Work on tests* Temporarily enable tests for the v13 branch* Increase coverage* Remove JobQueue.tick()# Was intended for interal use anyways# Fixes tests* Address review* Temporarily enable tests for the v13 branch* Address review* Dispatch errors* Fix handling of job_kwargs* Remove possibility to pass a Bot to JobQueue* Refactor persistence of Bot instances (#1994)* Refactor persistence of bots* User BP.set_bot in Dispatcher* Temporarily enable tests for the v13 branch* Add documentation* Add warning to Updater for passing both defaults and bot* Address review* Fix test
Bibo-Joshi added a commit that referenced this pull requestAug 16, 2020
* First go on refactoring JobQueue* Temporarily enable tests for the v13 branch* Work on tests* Temporarily enable tests for the v13 branch* Increase coverage* Remove JobQueue.tick()# Was intended for interal use anyways# Fixes tests* Address review* Temporarily enable tests for the v13 branch* Address review* Dispatch errors* Fix handling of job_kwargs* Remove possibility to pass a Bot to JobQueue
Bibo-Joshi added a commit that referenced this pull requestAug 16, 2020
* Refactor handling of `default_quote`* Make it a breaking change* Pickle a bots defaults* Temporarily enable tests for the v13 branch* Temporarily enable tests for the v13 branch* Refactor handling of kwargs in Bot methods (#1924)* Unify kwargs handling in Bot methods* Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class* Fix test_official* Update get_file methods* Refactor JobQueue (#1981)* First go on refactoring JobQueue* Temporarily enable tests for the v13 branch* Work on tests* Temporarily enable tests for the v13 branch* Increase coverage* Remove JobQueue.tick()# Was intended for interal use anyways# Fixes tests* Address review* Temporarily enable tests for the v13 branch* Address review* Dispatch errors* Fix handling of job_kwargs* Remove possibility to pass a Bot to JobQueue* Refactor persistence of Bot instances (#1994)* Refactor persistence of bots* User BP.set_bot in Dispatcher* Temporarily enable tests for the v13 branch* Add documentation* Add warning to Updater for passing both defaults and bot* Address review* Fix test
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsAug 17, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@jh0kerjh0kerjh0ker left review comments

@PoolitzerPoolitzerPoolitzer requested changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
13.0
Development

Successfully merging this pull request may close these issues.

Refactor JobQueue
3 participants
@Bibo-Joshi@jh0ker@Poolitzer

[8]ページ先頭

©2009-2025 Movatter.jp