utils
Functions:
-
mark_thread_pydev_do_not_trace–Modifies the given thread's attributes to hide or unhide it from the debugger (e.g., debugpy).
-
get_kernel–Get the current kernel.
-
get_job–Get the job for the current context.
-
get_parent–Get the parent message for the current context.
-
get_subshell_id–Get the
subshell_idfor the current context. -
subshell_context–A context manager to work in the context of a shell or subshell.
-
get_metadata–Gets the metadata for the current context.
-
get_tags–Gets the tags for the current context.
-
get_tag_value–Get the value for the tag from a collection of tags.
-
get_timeout–Gets the timeout from tags or using the current context.
-
get_execution_count–Gets the execution count for the current context, defaults to the current kernel count.
-
setattr_nested–Replace an existing nested attribute/trait of an object.
-
error_to_content–Convert the error to a dict.
-
redirect_stdout–Re-direct sys.stdout generated in the current context.
-
redirect_stderr–Re-direct sys.stderr generated in the current context.
mark_thread_pydev_do_not_trace
¶
mark_thread_pydev_do_not_trace(thread: Thread | None = None, *, remove=False) -> None
Modifies the given thread's attributes to hide or unhide it from the debugger (e.g., debugpy).
Source code in src/async_kernel/utils.py
53 54 55 56 57 58 | |
get_kernel
¶
get_kernel() -> Kernel
Get the current kernel.
Source code in src/async_kernel/utils.py
61 62 63 | |
get_job
¶
Get the job for the current context.
Raises:
-
LookupError–If there is no job in the current context.
Source code in src/async_kernel/utils.py
66 67 68 69 70 71 72 73 | |
get_parent
¶
Get the parent message for the current context.
Source code in src/async_kernel/utils.py
76 77 78 79 80 81 | |
get_subshell_id
¶
get_subshell_id() -> str | None
Get the subshell_id for the current context.
-
Reference
asyncshell
AsyncInteractiveSubshell
Source code in src/async_kernel/utils.py
84 85 86 | |
subshell_context
¶
subshell_context(subshell_id: str | None) -> Generator[None, Any, None]
A context manager to work in the context of a shell or subshell.
Parameters:
-
Reference
asyncshell
AsyncInteractiveSubshell
Source code in src/async_kernel/utils.py
89 90 91 92 93 94 95 96 97 | |
get_metadata
¶
Gets the metadata for the current context.
Source code in src/async_kernel/utils.py
100 101 102 103 104 105 | |
get_tags
¶
Gets the tags for the current context.
-
Reference
utils
get_tag_value
Source code in src/async_kernel/utils.py
108 109 110 111 112 113 | |
get_tag_value
¶
Get the value for the tag from a collection of tags.
Parameters:
-
(tag¶Tags) –The tag to get the value from.
-
(default¶_TagType) –The default value if a tag is not found. The default is also used to determine the type for conversion of the value.
-
(tags¶list[str] | None, default:None) –A list of tags to search. When not provide get_tags is used.
The tag value is the value trailing behind
Source code in src/async_kernel/utils.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
get_timeout
¶
Gets the timeout from tags or using the current context.
Source code in src/async_kernel/utils.py
148 149 150 151 152 | |
get_execution_count
¶
get_execution_count() -> int
Gets the execution count for the current context, defaults to the current kernel count.
Source code in src/async_kernel/utils.py
155 156 157 158 | |
setattr_nested
¶
Replace an existing nested attribute/trait of an object.
If the attribute name contains dots, it is interpreted as a nested attribute. For example, if name is "a.b.c", then the code will attempt to set obj.a.b.c to value.
Parameters:
-
(obj¶object) –The object to set the attribute on.
-
(name¶str) –The name of the attribute to set.
-
(value¶str | Any) –The value to set the attribute to.
Returns:
-
dict[str, Any]–The mapping of the name to the set value if the value has been set.
-
dict[str, Any]–An empty dict indicates the value was not set.
Source code in src/async_kernel/utils.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
error_to_content
¶
error_to_content(error: BaseException) -> Content
Convert the error to a dict.
ref: https://jupyter-client.readthedocs.io/en/stable/messaging.html#request-reply
Source code in src/async_kernel/utils.py
193 194 195 196 197 198 199 200 201 202 203 204 | |
redirect_stdout
¶
Re-direct sys.stdout generated in the current context.
See also
-
Reference
asyncshell
AsyncInteractiveShellsystem
Source code in src/async_kernel/utils.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
redirect_stderr
¶
Re-direct sys.stderr generated in the current context.
See also
-
Reference
asyncshell
AsyncInteractiveShellsystem
Source code in src/async_kernel/utils.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |