/opt/imh-python/lib/python3.9/site-packages/amqp
NameSizeModeActions
__pycache__/-0755rm
abstract_channel.py49410644editdlrm
basic_message.py33570644editdlrm
channel.py744750644editdlrm
connection.py275410644editdlrm
exceptions.py71660644editdlrm
method_framing.py67340644editdlrm
platform.py23790644editdlrm
protocol.py2910644editdlrm
sasl.py59860644editdlrm
serialization.py171620644editdlrm
spec.py21210644editdlrm
transport.py230460644editdlrm
utils.py14560644editdlrm
__init__.py23570644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/amqp/utils.py (1456B)
"""Compatibility utilities.""" import logging from logging import NullHandler # enables celery 3.1.23 to start again from vine import promise # noqa from vine.utils import wraps try: import fcntl except ImportError: # pragma: no cover fcntl = None # noqa def set_cloexec(fd, cloexec): """Set flag to close fd after exec.""" if fcntl is None: return try: FD_CLOEXEC = fcntl.FD_CLOEXEC except AttributeError: raise NotImplementedError( 'close-on-exec flag not supported on this platform', ) flags = fcntl.fcntl(fd, fcntl.F_GETFD) if cloexec: flags |= FD_CLOEXEC else: flags &= ~FD_CLOEXEC return fcntl.fcntl(fd, fcntl.F_SETFD, flags) def coro(gen): """Decorator to mark generator as a co-routine.""" @wraps(gen) def _boot(*args, **kwargs): co = gen(*args, **kwargs) next(co) return co return _boot def str_to_bytes(s): """Convert str to bytes.""" if isinstance(s, str): return s.encode('utf-8', 'surrogatepass') return s def bytes_to_str(s): """Convert bytes to str.""" if isinstance(s, bytes): return s.decode('utf-8', 'surrogatepass') return s def get_logger(logger): """Get logger by name.""" if isinstance(logger, str): logger = logging.getLogger(logger) if not logger.handlers: logger.addHandler(NullHandler()) return logger