Need Help , I am stuck at #jv8

I’m stuck on Stage #jv8

So I downloaded test case torrent files and it’s working locally,

But I am facing timeout for the same file on codecrafters test

This is 1 part of my code

@sayedMbo Could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.

Hi , yes here it is GitHub - bareXZ/codecrafters-bittorrent-python

@sayedMbo Got it. I’ll try to get back to you next week.

I checked again today, and it randomly passed all test cases. I am not sure what happened, but I hope I don’t face this issue again in the challenges ahead.

I had a similar issue in the past, in my case it was for two reasons:

  1. The test case picks one torrent randomly from a selection. If your implementation is slow then it might only pass when it gets lucky and the test case with the small file to download is selected.
  2. My code was very slow at downloading as it didn’t pipeline piece requests, i.e. it always waited to dowload a piece before requesting another piece. After implementing this my code was always fast enough at downloading to avoid the test timeouts. The guidance is a little misleading as it says this is an optional extra, but it’s really required in order to pass the tests consistently IME. FWIW I implemented downloading pieces from multiple peers in parallel before I added request pipelining, but this on its own was still too slow.
2 Likes

That makes sense, would be fun exploring this, thanks for your nice explanation

1 Like

the last pice might have smaller size than other pieces, you need to check file size and divide by number of pieces to check the last piece size.
Similar thing with last block of piece

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.