-
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
dc06e9c
commit 44a033d
Showing
23 changed files
with
275 additions
and
193 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
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
#!/usr/bin/env python | ||
|
||
import logging | ||
from asyncio import CancelledError | ||
from datetime import timedelta | ||
|
||
import anyio | ||
|
||
from justscheduleit import Scheduler, every | ||
|
||
logging.basicConfig() | ||
logging.getLogger("justscheduleit").setLevel(logging.DEBUG) | ||
|
||
scheduler = Scheduler() | ||
|
||
|
||
@scheduler.task(every(timedelta(seconds=5), delay=None)) | ||
async def long_async_task(): | ||
print(f"{long_async_task.__name__} is triggered!") | ||
try: | ||
await anyio.sleep(15) | ||
except CancelledError: | ||
# Won't be cancelled in the normal flow (graceful shutdown) | ||
print(f"Forced shutdown!") | ||
raise | ||
print(f"{long_async_task.__name__} has finished!") | ||
|
||
|
||
if __name__ == "__main__": | ||
import justscheduleit | ||
|
||
justscheduleit.run(scheduler) |
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
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
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
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
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
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
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,26 @@ | ||
#!/usr/bin/env python | ||
|
||
import time | ||
|
||
from examples.host.failing_service import host | ||
from justscheduleit.hosting import ServiceLifetime | ||
|
||
|
||
@host.service(main=True) | ||
def a_main_sync_service(service_lifetime: ServiceLifetime): | ||
print(f"{a_main_sync_service.__name__} started") | ||
service_lifetime.set_started() | ||
crash_countdown = 5 | ||
while not service_lifetime.shutting_down.is_set(): | ||
print(f"{a_main_sync_service.__name__} running") | ||
time.sleep(1) | ||
crash_countdown -= 1 | ||
if crash_countdown == 0: | ||
raise RuntimeError("This is a test error from _sync_") | ||
print(f"{a_main_sync_service.__name__} stopped") | ||
|
||
|
||
if __name__ == "__main__": | ||
from justscheduleit import hosting | ||
|
||
exit(hosting.run(host)) |
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
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
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
File renamed without changes.
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
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
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
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
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
Oops, something went wrong.