Making sure a block of code takes at least 5 seconds to execute
Rather than waiting for 5 second between calls, consider that Twitter API returns three HTTP headers that explicitly tells you your quota:


  
  X-Rate-Limit-Limit: the rate limit ceiling for that given request
  X-Rate-Limit-Remaining: the number of requests left for the 15 minute window
  X-Rate-Limit-Reset: the remaining window before the rate limit resets in UTC epoch seconds
  


You can just query as much as you like, until the X-Rate-Limit-Remaining reaches zero or until you receive a 429 Too Many Request status code, then sleep for X-Rate-Limit-Reset.

This gives you several advantages:


You're utilising your limit to the fullest
If twitter changes their rate limit (e.g. someone is DDoSing them and they need to stricken it up or they make a significant upgrade that allows them to increase their quota), then your application will automatically adapt.
sleeping can't take into account of the per-user quota when you share access tokens for multiple applications/multiple purposes


Refer to Twitter documentation: https://dev.twitter.com/docs/rate-limiting/1.1