$90 GRAYBYTE WORDPRESS FILE MANAGER $89

SERVER : in-mum-web1330.main-hosting.eu #1 SMP Mon Feb 10 22:45:17 UTC 2025
SERVER IP : 91.108.106.185 | ADMIN IP 216.73.216.215
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/python311/lib/python3.11/site-packages/loguru/

HOME
Current File : /opt/alt/python311/lib/python3.11/site-packages/loguru//_simple_sinks.py
import asyncio
import logging
import weakref

from ._asyncio_loop import get_running_loop, get_task_loop


class StreamSink:
    def __init__(self, stream):
        self._stream = stream
        self._flushable = callable(getattr(stream, "flush", None))
        self._stoppable = callable(getattr(stream, "stop", None))
        self._completable = asyncio.iscoroutinefunction(getattr(stream, "complete", None))

    def write(self, message):
        self._stream.write(message)
        if self._flushable:
            self._stream.flush()

    def stop(self):
        if self._stoppable:
            self._stream.stop()

    def tasks_to_complete(self):
        if not self._completable:
            return []
        return [self._stream.complete()]


class StandardSink:
    def __init__(self, handler):
        self._handler = handler

    def write(self, message):
        record = message.record
        message = str(message)
        exc = record["exception"]
        record = logging.getLogger().makeRecord(
            record["name"],
            record["level"].no,
            record["file"].path,
            record["line"],
            message,
            (),
            (exc.type, exc.value, exc.traceback) if exc else None,
            record["function"],
            {"extra": record["extra"]},
        )
        if exc:
            record.exc_text = "\n"
        self._handler.handle(record)

    def stop(self):
        self._handler.close()

    def tasks_to_complete(self):
        return []


class AsyncSink:
    def __init__(self, function, loop, error_interceptor):
        self._function = function
        self._loop = loop
        self._error_interceptor = error_interceptor
        self._tasks = weakref.WeakSet()

    def write(self, message):
        try:
            loop = self._loop or get_running_loop()
        except RuntimeError:
            return

        coroutine = self._function(message)
        task = loop.create_task(coroutine)

        def check_exception(future):
            if future.cancelled() or future.exception() is None:
                return
            if not self._error_interceptor.should_catch():
                raise future.exception()
            self._error_interceptor.print(message.record, exception=future.exception())

        task.add_done_callback(check_exception)
        self._tasks.add(task)

    def stop(self):
        for task in self._tasks:
            task.cancel()

    def tasks_to_complete(self):
        # To avoid errors due to "self._tasks" being mutated while iterated, the
        # "tasks_to_complete()" method must be protected by the same lock as "write()" (which
        # happens to be the handler lock). However, the tasks must not be awaited while the lock is
        # acquired as this could lead to a deadlock. Therefore, we first need to collect the tasks
        # to complete, then return them so that they can be awaited outside of the lock.
        return [self._complete_task(task) for task in self._tasks]

    async def _complete_task(self, task):
        loop = get_running_loop()
        if get_task_loop(task) is not loop:
            return
        try:
            await task
        except Exception:
            pass  # Handled in "check_exception()"

    def __getstate__(self):
        state = self.__dict__.copy()
        state["_tasks"] = None
        return state

    def __setstate__(self, state):
        self.__dict__.update(state)
        self._tasks = weakref.WeakSet()


class CallableSink:
    def __init__(self, function):
        self._function = function

    def write(self, message):
        self._function(message)

    def stop(self):
        pass

    def tasks_to_complete(self):
        return []

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
5 Sep 2025 9.32 AM
root / 996
0755
__pycache__
--
8 May 2024 6.34 PM
root / root
0755
__init__.py
0.611 KB
8 May 2024 6.34 PM
root / root
0644
__init__.pyi
14.098 KB
8 May 2024 6.34 PM
root / root
0644
_asyncio_loop.py
0.583 KB
8 May 2024 6.34 PM
root / root
0644
_better_exceptions.py
19.527 KB
8 May 2024 6.34 PM
root / root
0644
_colorama.py
1.634 KB
8 May 2024 6.34 PM
root / root
0644
_colorizer.py
14.259 KB
8 May 2024 6.34 PM
root / root
0644
_contextvars.py
0.313 KB
8 May 2024 6.34 PM
root / root
0644
_ctime_functions.py
1.495 KB
8 May 2024 6.34 PM
root / root
0644
_datetime.py
3.669 KB
8 May 2024 6.34 PM
root / root
0644
_defaults.py
2.86 KB
8 May 2024 6.34 PM
root / root
0644
_error_interceptor.py
1.081 KB
8 May 2024 6.34 PM
root / root
0644
_file_sink.py
14.186 KB
8 May 2024 6.34 PM
root / root
0644
_filters.py
0.604 KB
8 May 2024 6.34 PM
root / root
0644
_get_frame.py
0.447 KB
8 May 2024 6.34 PM
root / root
0644
_handler.py
12.338 KB
8 May 2024 6.34 PM
root / root
0644
_locks_machinery.py
1.276 KB
8 May 2024 6.34 PM
root / root
0644
_logger.py
93.723 KB
8 May 2024 6.34 PM
root / root
0644
_recattrs.py
2.795 KB
8 May 2024 6.34 PM
root / root
0644
_simple_sinks.py
3.646 KB
8 May 2024 6.34 PM
root / root
0644
_string_parsers.py
4.597 KB
8 May 2024 6.34 PM
root / root
0644
py.typed
0 KB
8 May 2024 6.34 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF