In this homework, you will extend the Session 5 capstone project by adding controlled parallel video downloading.
You will:
- revisit your Session 5 capstone repository
- add 5 more short YouTube video URLs
- limit parallel video downloads to 5 at a time
- use a semaphore to coordinate shared result-file writing
- record clear success/failure output for each video
Use the separate capstone repository from Session 5:
Do not write your capstone solution files in this weekly bda repository.
- Open your fork of the Session 5 capstone repository.
- Pull the latest changes from your fork.
- Find 5 additional short YouTube videos.
- Add the 5 new URLs to your capstone input list.
- Update your downloader so no more than 5 videos download at the same time.
- Use
threading.Semaphore(5)or an equivalent semaphore to enforce the download limit. - Use a semaphore or lock-style protected section when writing results to a shared results file.
- Record one result line per video:
- URL
- status (
successorfailed) - output filename or error message
- timestamp
- Test your program with the expanded URL list.
- Commit and push your updated capstone work.
Use one semaphore for the download limit:
download_limit = threading.Semaphore(5)Use another one-at-a-time guard for the shared results file:
result_file_guard = threading.Semaphore(1)This is intentionally similar to a mutex. It allows exactly one worker to write to the file at a time.
Create this file:
session6/solutions/exercise-06-homework.mdYour markdown file should include:
# Session 6 Homework
## Capstone repository
Link:
## New YouTube URLs
1.
2.
3.
4.
5.
## What I changed
Explain how you limited parallel downloads to 5.
## Semaphore design
Explain where you used the download semaphore and where you protected result-file writing.
## Result file format
Show 2-3 example result lines from your output file.
## Testing
Explain how you tested that only 5 downloads can run at once.
## Reflection
What was harder: limiting downloads or safely writing results? Why?- Use Python.
- Use a semaphore for the parallel download limit.
- Add exactly 5 additional short YouTube URLs.
- Do not overwrite old capstone results without backing them up or clearly regenerating them.
- Record failures instead of hiding them.
- Keep your code readable enough for another student to follow.
Post your completed session6/solutions/exercise-06-homework.md in the class discussion forum.
Use the MS Teams discussion forum:
When you post, include:
- your capstone repository link
- your 5 new video URLs
- a short explanation of your semaphore design