This file contains hidden or 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
from typing import List | |
from threading import Thread, RLock, Event | |
import time | |
import uuid | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger(__name__) | |
This file contains hidden or 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
from typing import Any, Callable, Type | |
from functools import wraps | |
class Singleton(type): | |
_instances = {} | |
def __call__(cls: Type[Any], *args: Any, **kwargs: Any) -> Any: | |
'''Gets as input the class and args/kwargs and returns either an already | |
instantiated object or a new object from that class''' |
This file contains hidden or 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
function promisify(func, context) { | |
return function(...p) { | |
return new Promise(function(resolve, reject) { | |
p.push(function(err, data) { | |
if (err) { | |
reject(err) | |
} else { | |
resolve(data) | |
} | |
}) |