N̷̪̞͈̓̀̒ͅi̵̩̺̋̊̀̆̿̂͊̇s̷͚͕͙͈̙̻̀̓͛̇͐͗̿̈̿͠ͅḧ̵͍̻́̑̽̆̇͂̈̈́a̴̧̡͈̥̜͑̄͆ͅń̶̨̧̹̤͍̹̙͛̓͘͜ͅt̵͖̳̣͎̦̰̱̖̬̐̐̓͂͆͠ͅh̴̢̨̛͇̘̪͖̼͚̋̌͂̀̅̍̀̕̚ͅͅ ̷̹͕̩̮̇̾̈̈̐͝ͅR̸͖̀͊̀̎͊́͛̒͘͘ę̴̟͍̣̻͈̮̝̫̞͘d̴͓̺̺̙͖̥̫̣͕̈́͛̅̍͑d̶̜̰̠͓̦̳̟̤̀̿̕y̵̩̮̿̎͐̍̃̃̚͝͠ remidinishanth-ntnx
🎯
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
import asyncio | |
from datetime import datetime, timezone | |
import os | |
def utc_now(): | |
# utcnow returns a naive datetime, so we have to set the timezone manually <sigh> | |
return datetime.utcnow().replace(tzinfo=timezone.utc) | |
class Terminator: | |
pass |
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
#!/usr/bin/env python2 | |
from threading import Event, Thread | |
class Periodic(object): | |
"""Periodically run a function with arguments asynchronously in the background | |
Period is a float of seconds. | |
Don't expect exact precision with timing. | |
Threading is used instead of Multiprocessing because we need shared memory |
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
import logging | |
import threading | |
class PeriodicThread(object): | |
""" | |
Python periodic Thread using Timer with instant cancellation | |
""" | |
def __init__(self, callback=None, period=1, name=None, *args, **kwargs): |