-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12445e4
commit fe6dbdf
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
2022-12-11 | ||
========== | ||
|
||
Added | ||
----- | ||
|
||
- The first version of the package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
A simple package to make retry loops easier | ||
|
||
### Usage: | ||
|
||
```python | ||
from retimer import Timer | ||
import time | ||
|
||
timer = Timer(10) | ||
while timer.not_expired: | ||
# do something for 10 seconds | ||
|
||
if retry_doing_something: | ||
time.sleep(.5) # good if something is a request to a server or cpu intensive | ||
continue | ||
if something_bad: | ||
timer.explode() | ||
|
||
# all good so we break before timer expires | ||
break | ||
|
||
if timer.expired: | ||
print("Could not do something after tried for 10 seconds") | ||
else: | ||
print("Successfully did something after 10 seconds") | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters