event_loop
- Reference typing
Classes:
-
Host–A class that provides the necessary callbacks for
start_guest_run.
Functions:
Host
¶
Bases: Generic[T]
A class that provides the necessary callbacks for start_guest_run.
- Usage Command line and kernel configuration Loop options
-
Reference
event_loop
run
-
Reference
event_loop
Hostcurrent
Methods:
-
current–The host running in the corresponding thread or current thread.
-
run–Run the loop in the current thread with a backend guest.
-
mainloop–Start the main event loop of the host.
Attributes:
-
start_guest(Callable[[], Any]) –A callback to start the guest. This must be called by a subclass.
Source code in src/async_kernel/event_loop/run.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
start_guest
class-attribute
instance-attribute
¶
start_guest: Callable[[], Any] = staticmethod(lambda: None)
A callback to start the guest. This must be called by a subclass.
current
classmethod
¶
The host running in the corresponding thread or current thread.
Source code in src/async_kernel/event_loop/run.py
98 99 100 101 102 | |
run
classmethod
¶
run(
func: Callable[..., CoroutineType[Any, Any, T]], args: tuple, settings: RunSettings
) -> T
Run the loop in the current thread with a backend guest.
Source code in src/async_kernel/event_loop/run.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
mainloop
¶
mainloop() -> T
Start the main event loop of the host.
Source code in src/async_kernel/event_loop/run.py
163 164 165 166 167 168 169 | |
run
¶
run(
func: Callable[..., CoroutineType[Any, Any, T]], args: tuple, settings: RunSettings
) -> T
Run func to completion asynchronously in the current thread using a backend
with an optional gui event loop (host).
The default backend is 'asyncio'.
If loop is specified in settings. A host (gui) mainloop
will be started with the backend running as a guest (in the same thread). The backend
will execute func asynchronously to completion. Once completed the backend and host
are stopped and finally the result is returned.
Parameters:
-
(func¶Callable[..., CoroutineType[Any, Any, T]]) –A coroutine function.
-
(args¶tuple) –Args to use when calling func.
-
(settings¶RunSettings) –Settings to use when running func.
Custom loop
A custom event loop can be used by subclassing Host. The host can be specified in the settings as the option 'host_class'. The value can be the class or a dotted path if it is importable.
Source code in src/async_kernel/event_loop/run.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |