Bite 204. Pomodoro with asyncio
Login and get codingThis Bite explores asyncio and type-hinting.
For this bite, you will be taking a simple Pomodoro timer and refactoring it to utilize asynchronous coroutines with the
asyncandawaitkeywords. You will also need to add type hinting to the code.It's not the best example of it, but it will give you some hands on practice with how it flows together. The pomodoro code works as is, but the tests will be calling the functions with the
asynckeyword.The code outputs the following with the dummy data:
Pomodor timer started at: 22:13:56 Session: 1 [1] 22:13:56 Time to work! [1] 22:13:56 Time for a 0 min break! [2] 22:13:56 Time to work! [2] 22:13:56 Time for a 0 min break! [3] 22:13:56 Time to work! [3] 22:13:56 Time for a 0 min break! [4] 22:13:56 Time to work! [4] 22:13:56 Time for a 0 min break! Session: 2 [1] 22:13:56 Time to work! [1] 22:13:56 Time for a 0 min break! [2] 22:13:56 Time to work! [2] 22:13:56 Time for a 0 min break! [3] 22:13:56 Time to work! [3] 22:13:56 Time for a 0 min break! [4] 22:13:56 Time to work! ** 22:13:56 Time for lunch! ** Session: 3 [1] 22:13:56 Time to work! [1] 22:13:56 Time for a 0 min break! [2] 22:13:56 Time to work! [2] 22:13:56 Time for a 0 min break! [3] 22:13:56 Time to work! [3] 22:13:56 Time for a 0 min break! [4] 22:13:56 Time to work! [4] 22:13:56 Time for a 0 min break! Session: 4 [1] 22:13:56 Time to work! [1] 22:13:56 Time for a 0 min break! [2] 22:13:56 Time to work! [2] 22:13:56 Time for a 0 min break! [3] 22:13:56 Time to work! [3] 22:13:56 Time for a 0 min break! [4] 22:13:56 Time to work! 22:13:56 Time to go home! Work day completed at: 22:13:56If run with the commented code, it would take about 8 hours to complete!
Have fun!
70 out of 74 users completed this Bite.
Will you be the 71st person to crack this Bite?
Resolution time: ~54 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 4.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪