# Tweets From Will McGugan

URL:: https://twitter.com/willmcgugan
Author:: @willmcgugan on Twitter
## Highlights
> A #Python tip I don't think I've come across before.
> Don't use sleep() in threads.
> Why? They can't be interrupted. If you want to wait 60 seconds between tasks you can't exit the sleep prematurely.
> Solution? Use threading.Event and wait(). Set the event to interrupt the sleep. ([View Tweet](https://twitter.com/search?q=A%20%23Python%20tip%20I%20don%27t%20think%20I%27ve%20come%20across%20before.%20%20Don%27t%20use%20sleep%28%29%20in%20threads.%20%20Why%3F%20They%20can%27t%20be%20interrupted.%20If%20you%20want%20to%20wait%2060%20seconds%20between%20tasks%20you%20can%27t%20exit%20the%20sleep%20prematurely.%20%20Solution%3F%20Use%20threading.Event%20and%20wait%28%20%28from%3A%40willmcgugan%29))
---
Title: Tweets From Will McGugan
Author: @willmcgugan on Twitter
Tags: readwise, tweets
date: 2024-01-30
---
# Tweets From Will McGugan

URL:: https://twitter.com/willmcgugan
Author:: @willmcgugan on Twitter
## AI-Generated Summary
None
## Highlights
> A #Python tip I don't think I've come across before.
> Don't use sleep() in threads.
> Why? They can't be interrupted. If you want to wait 60 seconds between tasks you can't exit the sleep prematurely.
> Solution? Use threading.Event and wait(). Set the event to interrupt the sleep. ([View Tweet](https://twitter.com/search?q=A%20%23Python%20tip%20I%20don%27t%20think%20I%27ve%20come%20across%20before.%20%20Don%27t%20use%20sleep%28%29%20in%20threads.%20%20Why%3F%20They%20can%27t%20be%20interrupted.%20If%20you%20want%20to%20wait%2060%20seconds%20between%20tasks%20you%20can%27t%20exit%20the%20sleep%20prematurely.%20%20Solution%3F%20Use%20threading.Event%20and%20wait%28%20%28from%3A%40willmcgugan%29))