Psyduck - 可達鴨 之 鴨力山大2


Server : LiteSpeed
System : Linux premium217.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User : alloknri ( 880)
PHP Version : 8.1.34
Disable Function : NONE
Directory :  /opt/alt/python311/lib64/python3.11/asyncio/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python311/lib64/python3.11/asyncio/__main__.py
import ast
import asyncio
import code
import concurrent.futures
import inspect
import sys
import threading
import types
import warnings

from . import futures


class AsyncIOInteractiveConsole(code.InteractiveConsole):

    def __init__(self, locals, loop):
        super().__init__(locals)
        self.compile.compiler.flags |= ast.PyCF_ALLOW_TOP_LEVEL_AWAIT

        self.loop = loop

    def runcode(self, code):
        future = concurrent.futures.Future()

        def callback():
            global repl_future
            global repl_future_interrupted

            repl_future = None
            repl_future_interrupted = False

            func = types.FunctionType(code, self.locals)
            try:
                coro = func()
            except SystemExit:
                raise
            except KeyboardInterrupt as ex:
                repl_future_interrupted = True
                future.set_exception(ex)
                return
            except BaseException as ex:
                future.set_exception(ex)
                return

            if not inspect.iscoroutine(coro):
                future.set_result(coro)
                return

            try:
                repl_future = self.loop.create_task(coro)
                futures._chain_future(repl_future, future)
            except BaseException as exc:
                future.set_exception(exc)

        loop.call_soon_threadsafe(callback)

        try:
            return future.result()
        except SystemExit:
            raise
        except BaseException:
            if repl_future_interrupted:
                self.write("\nKeyboardInterrupt\n")
            else:
                self.showtraceback()


class REPLThread(threading.Thread):

    def run(self):
        try:
            banner = (
                f'asyncio REPL {sys.version} on {sys.platform}\n'
                f'Use "await" directly instead of "asyncio.run()".\n'
                f'Type "help", "copyright", "credits" or "license" '
                f'for more information.\n'
                f'{getattr(sys, "ps1", ">>> ")}import asyncio'
            )

            console.interact(
                banner=banner,
                exitmsg='exiting asyncio REPL...')
        finally:
            warnings.filterwarnings(
                'ignore',
                message=r'^coroutine .* was never awaited$',
                category=RuntimeWarning)

            loop.call_soon_threadsafe(loop.stop)


if __name__ == '__main__':
    sys.audit("cpython.run_stdin")

    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)

    repl_locals = {'asyncio': asyncio}
    for key in {'__name__', '__package__',
                '__loader__', '__spec__',
                '__builtins__', '__file__'}:
        repl_locals[key] = locals()[key]

    console = AsyncIOInteractiveConsole(repl_locals, loop)

    repl_future = None
    repl_future_interrupted = False

    try:
        import readline  # NoQA
    except ImportError:
        pass

    repl_thread = REPLThread()
    repl_thread.daemon = True
    repl_thread.start()

    while True:
        try:
            loop.run_forever()
        except KeyboardInterrupt:
            if repl_future and not repl_future.done():
                repl_future.cancel()
                repl_future_interrupted = True
            continue
        else:
            break
Name
Size
Permissions
Options
__pycache__
--
drwxr-xr-x
__init__.py
1.16 KB
-rw-r--r--
__main__.py
3.3 KB
-rw-r--r--
base_events.py
73.617 KB
-rw-r--r--
base_futures.py
1.957 KB
-rw-r--r--
base_subprocess.py
8.661 KB
-rw-r--r--
base_tasks.py
2.582 KB
-rw-r--r--
constants.py
1.295 KB
-rw-r--r--
coroutines.py
3.32 KB
-rw-r--r--
events.py
27.97 KB
-rw-r--r--
exceptions.py
1.711 KB
-rw-r--r--
format_helpers.py
2.348 KB
-rw-r--r--
futures.py
13.879 KB
-rw-r--r--
locks.py
18.568 KB
-rw-r--r--
log.py
0.121 KB
-rw-r--r--
mixins.py
0.47 KB
-rw-r--r--
proactor_events.py
32.484 KB
-rw-r--r--
protocols.py
6.794 KB
-rw-r--r--
queues.py
7.787 KB
-rw-r--r--
runners.py
6.682 KB
-rw-r--r--
selector_events.py
44.336 KB
-rw-r--r--
sslproto.py
30.995 KB
-rw-r--r--
staggered.py
5.852 KB
-rw-r--r--
streams.py
26.858 KB
-rw-r--r--
subprocess.py
7.502 KB
-rw-r--r--
taskgroups.py
8.272 KB
-rw-r--r--
tasks.py
33.626 KB
-rw-r--r--
threads.py
0.771 KB
-rw-r--r--
timeouts.py
5.196 KB
-rw-r--r--
transports.py
10.471 KB
-rw-r--r--
trsock.py
2.417 KB
-rw-r--r--
unix_events.py
50.698 KB
-rw-r--r--
windows_events.py
33.878 KB
-rw-r--r--
windows_utils.py
4.941 KB
-rw-r--r--