Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored tracker health check code to become asynchronous. Adjusted a part of the tribler shutdown procedure as a result. #2038

Merged
merged 2 commits into from
Apr 25, 2016

Conversation

lfdversluis
Copy link

@lfdversluis lfdversluis commented Mar 15, 2016

More deletions than additions while keeping the same functionality (I hope), but much more clean!

  • HTTP tracker code now makes use of Twisted's RedirectAgent. This means it will automatically redirect when a 30x code is returned, is asynchronous and has a timeout implemented.
  • The UDP tracker is now asynchronous, has a timeout added and has some bug fixes.
  • Shutdown of a UDP connection is now asynchronous, this is propogated in Tribler where it preparations are made for other components to shutdown asynchronous as well by using Deferreds.

Fixes #2035, contributing to #1848

Adds 29 tests
Improves responsiveness a lot, watchdog was tripping with > 10 seconds timeout. Not anymore.
Fixed 2 bugs
Improved redirection by making use of Twisted's redirectAgent
Added lots of documentation for other generations to read (enchancement)
Fixed 50+ pylint style errors

@lfdversluis
Copy link
Author

Dirty reactor

@lfdversluis
Copy link
Author

retest this please

@lfdversluis
Copy link
Author

again dirty reactor

@lfdversluis
Copy link
Author

retest this please

@lfdversluis
Copy link
Author

Again a dirty reactor. I think the test gets a deferred now and terminates immediately. Will check tomorrow.

@whirm whirm added the WIP label Mar 16, 2016
@lfdversluis lfdversluis changed the title Made the HTTP tracker async, in 1 commit! Refactored the HTTP tracker query code to become asynchronous Mar 17, 2016
@lfdversluis
Copy link
Author

retest this please

@lfdversluis
Copy link
Author

It was correct! Let's see if 2/2 pass :)

@lfdversluis
Copy link
Author

retest this please

@lfdversluis
Copy link
Author

@whirm if this one succeeds too, I think it should be OK.

@lfdversluis
Copy link
Author

retest this please

@whirm
Copy link

whirm commented Mar 18, 2016

No need to retest, you need to fix this first:

ERROR   1458311111  test_as_server:TestGuiDialogs:122  The reactor was dirty:
ERROR   1458311111  test_as_server:TestGuiDialogs:124  >     <DelayedCall 0x7f1328ca0638 [48.7743420601s] called=0 cancelled=0 ThreadedResolver._cleanup('tracker.yify-torrents.com', <Deferred at 0x7f1328ca08c0>)>

@lfdversluis lfdversluis changed the title Refactored the HTTP tracker query code to become asynchronous Refactored tracker health check code to become asynchronous Mar 23, 2016
@lfdversluis lfdversluis force-pushed the httptracker-async branch 6 times, most recently from d5f18ff to 3d6a91b Compare March 24, 2016 10:16
@lfdversluis
Copy link
Author

@whirm Dispersy is down according to @devos50. My code seems to be working fine but the tunnelcommunity tests are now failing and leaving stuff behind.

@whirm
Copy link

whirm commented Mar 29, 2016

retest this please

@lfdversluis
Copy link
Author

Jenkins is down, can't see the diff in coverage :/

@lfdversluis
Copy link
Author

Looks like the hiccup is over

@lfdversluis lfdversluis changed the title Refactored tracker health check code to become asynchronous Refactored tracker health check code to become asynchronous. Adjusted a part of the tribler shutdown procedure as a result. Mar 31, 2016
@lfdversluis lfdversluis force-pushed the httptracker-async branch 2 times, most recently from 5ddd214 to 2418cb5 Compare March 31, 2016 14:06
@lfdversluis
Copy link
Author

@whirm Ok, tests are all passing on it again... I will squash now.

@whirm
Copy link

whirm commented Apr 22, 2016

great!

@lfdversluis lfdversluis force-pushed the httptracker-async branch 2 times, most recently from ebc5a6f to 44bdcd3 Compare April 22, 2016 10:44
@lfdversluis
Copy link
Author

lfdversluis commented Apr 22, 2016

https://jenkins.tribler.org/job/GH_Tribler_PR_tests_linux/899/artifact/output/test_runners_output/00003.err/*view*/

Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/jenkins/workspace/GH_Tribler_PR_tests_linux/tribler/Tribler/Core/Utilities/twisted_thread.py", line 55, in _reactor_runner
    reactor.run(installSignalHandlers=False)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 1194, in run
    self.mainLoop()
  File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 1203, in mainLoop
    self.runUntilCurrent()
--- <exception caught here> ---
  File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 798, in runUntilCurrent
    f(*a, **kw)
  File "/home/jenkins/workspace/GH_Tribler_PR_tests_linux/tribler/Tribler/dispersy/endpoint.py", line 250, in dispersythread_data_came_in
    u"standalone_ep")
  File "/home/jenkins/workspace/GH_Tribler_PR_tests_linux/tribler/Tribler/dispersy/dispersy.py", line 1445, in on_incoming_packets
    assert all(len(packet[1]) > 22 for packet in packets), packets
exceptions.AssertionError: [(<Tribler.dispersy.candidate.Candidate object at 0x7f331c0a7ad0>, 'A\x00\xb7Y&&\x97\x01\x00\x00\x00\x00\x00\x10\x00\x00\x18\xc6\x00\x00')]

Haven't seen this one before.

@whirm
Copy link

whirm commented Apr 22, 2016

I don't think receiving a 17byte datagram should raise an exception...

I'll have a look on the dispersy side.

@lfdversluis
Copy link
Author

retest this please

@lfdversluis
Copy link
Author

test_download_torrent_from_file (Tribler.Test.API.test_download.TestDownload) ... /home/jenkins/workspace/GH_Tribler_PR_tests_linux@2/gumby/scripts/wrap_in_temp_home.sh: line 34: 11081 Terminated

@lfdversluis
Copy link
Author

retest this please

@lfdversluis lfdversluis changed the title READY: Refactored tracker health check code to become asynchronous. Adjusted a part of the tribler shutdown procedure as a result. WIP: Refactored tracker health check code to become asynchronous. Adjusted a part of the tribler shutdown procedure as a result. Apr 22, 2016
@lfdversluis
Copy link
Author

Found an issue that may be related to my work

@lfdversluis
Copy link
Author

@whirm tests passed 👍

@lfdversluis
Copy link
Author

lfdversluis commented Apr 22, 2016

Huh again an one line but not the second covered issue. But this time not a continue

@whirm
Copy link

whirm commented Apr 22, 2016

Looks fine, squash it

…ous, fixed styling issues, 2 bugs, added a utility function and reduced overall code and complexity
@lfdversluis lfdversluis changed the title WIP: Refactored tracker health check code to become asynchronous. Adjusted a part of the tribler shutdown procedure as a result. READY: Refactored tracker health check code to become asynchronous. Adjusted a part of the tribler shutdown procedure as a result. Apr 22, 2016
@lfdversluis
Copy link
Author

retest this please

@whirm
Copy link

whirm commented Apr 22, 2016

@lfdversluis are all tests passing locally for you? I find it a bit suspicious that the bucket that gets stuck is the one that contains the new tests.

@lfdversluis
Copy link
Author

@whirm Yup Locally they run fine. Perhaps debian vs ubuntu? We know that download_from_url hangs on devel, and other tests


self.tdb.addExternalTorrent(tdef)
self.session.check_torrent_health(tdef.get_infohash())
sleep(31)
Copy link

Choose a reason for hiding this comment

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

No sleeps please

Copy link
Author

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

That sucks, it slipped right through.

@devos50 please, fix that test to not use sleep().

Copy link
Contributor

Choose a reason for hiding this comment

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

@whirm it's also not my test, I only made a modification to the test to let it use another torrent. I will create an issue.

Copy link

Choose a reason for hiding this comment

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

To me it looks like the whole test is being added on this PR.

Copy link

Choose a reason for hiding this comment

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

It's really weird.

Copy link

Choose a reason for hiding this comment

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

Oh man, it's a Monday alright! That's a copy of the test over it... Those two tests are responsible for a full minute of test execution time. That's ridiculous.

@lfdversluis
Copy link
Author

lfdversluis commented Apr 25, 2016

@whirm As you made a separate issue for the sleep(s), can this one be merged if all is/looks ok? AFAIK @ardhipoetra would like to rebase with this code as he has the current blocking code in his work now (and he depends on the statistics).

IF it turns out that there is indeed something weird going on with the tests (your gut feeling) besides the hanging stuff that will get fixed, I will open a new PR once I investigated.

@devos50
Copy link
Contributor

devos50 commented Apr 25, 2016

I'm also dependent on this PR since I have to refactor the shutdown procedure of the HTTP API slightly as well so I would also like to see this merged before #2121.

@whirm whirm changed the title READY: Refactored tracker health check code to become asynchronous. Adjusted a part of the tribler shutdown procedure as a result. efactored tracker health check code to become asynchronous. Adjusted a part of the tribler shutdown procedure as a result. Apr 25, 2016
@whirm whirm changed the title efactored tracker health check code to become asynchronous. Adjusted a part of the tribler shutdown procedure as a result. Refactored tracker health check code to become asynchronous. Adjusted a part of the tribler shutdown procedure as a result. Apr 25, 2016
@whirm whirm merged commit f767649 into Tribler:devel Apr 25, 2016
@ardhipoetra
Copy link

Thanks for the merge! Will do the rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Make the torrent health checking asynchronous
4 participants