Skip to content

Conversation

@ExalFabu
Copy link
Contributor

This should resolve #3105
I strictly followed #3078, I hope I've not missed any documentation that was required to change as well

Anyway, as I mentioned in the issue i am struggling with these test that i added:

  • test_run_polling_post_shutdown
  • test_run_webhook_post_shutdown

Here's a screenshot of the error (it's the same for both tests)
image

I don't know if I've messed up the test itself or I'm missing something

ExalFabu added 2 commits June 27, 2022 22:14
Tests not succesful:
- test_run_polling_post_shutdown
- test_run_webhook_post_shutdown

It is beyond my knowledge the reason why these 2 tests fails.
Somehow Updater.shutdown is called two times
@harshil21 harshil21 added enhancement 📋 pending-review work status: pending-review labels Jun 28, 2022
@harshil21 harshil21 added this to the v20.0a3 milestone Jun 28, 2022
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I left two comments below

ExalFabu and others added 2 commits June 29, 2022 07:49
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
@ExalFabu
Copy link
Contributor Author

ExalFabu commented Jun 29, 2022

I fixed and removed that duplicated line of code and the tests i wrote passed.
Though it seems another test broke: test_run_error_in_application, only when the error is simulated inside application.initialize()

And for what I understand it's really not an issue, since at this point of the execution the updater hasn't been initialized yet, and that's why app.shutdown() doesn't call updater.shutdown()

If my assumptions are correct, i may fix the test asserting app._initialized and app.updater._initilized as false, removing the need to monkeypatch the methods
Alternatively i can assert the two different cases inside a if statement
Something like assert set(shutdowns) == ( {"application", "updater"} if method == "start" else {"application"} )

Edit: I've tested this second option and i can commit it as soon i as i have a green light :)

Edit 2: I think that what i wrote before was entirely wrong, so i leave it up to you big guys to help me understand where the issue is and I'll try and fix it for you

@Bibo-Joshi
Copy link
Member

The bad boy is this here:

if not self._initialized:
_logger.debug("This Application is already shut down. Returning.")
return

this tells Application.shutdown to just exit if the app wasn't properly initialized and hence Updater.shutdown is not called.
While we can't be 100% sure that Updater.initialize wasn't called by Application.initialize, I'm okay with that. Catching all errors that can happen during startup is a kind of a sisyphus task, so a best effort suffices IMO.

@Bibo-Joshi Bibo-Joshi marked this pull request as ready for review June 29, 2022 20:41
@Bibo-Joshi Bibo-Joshi requested a review from harshil21 June 29, 2022 20:41
Copy link
Member

@harshil21 harshil21 left a comment

Choose a reason for hiding this comment

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

just one comment

Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
@Bibo-Joshi Bibo-Joshi merged commit 1f0f6a8 into python-telegram-bot:master Jul 3, 2022
@Bibo-Joshi
Copy link
Member

Thank you for the contribution :)

@github-actions github-actions bot locked and limited conversation to collaborators Jul 10, 2022
@harshil21 harshil21 removed the 📋 pending-review work status: pending-review label Jul 23, 2022
@Bibo-Joshi Bibo-Joshi added 🔌 enhancement pr description: enhancement and removed enhancement labels Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🔌 enhancement pr description: enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

post_shutdown method in addition to post_init

3 participants