Skip to content

Commit 568a433

Browse files
committed
Render traceback with the options of the target console in the main process.
1 parent e8b7dbf commit 568a433

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/pytask_parallel/execute.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from _pytask.report import ExecutionReport
1111
from _pytask.traceback import remove_internal_traceback_frames_from_exc_info
1212
from pytask_parallel.backends import PARALLEL_BACKENDS
13+
from rich.console import ConsoleOptions
1314
from rich.traceback import Traceback
1415

1516

@@ -151,10 +152,11 @@ def pytask_execute_task(session, task): # noqa: N805
151152
_unserialize_and_execute_task,
152153
bytes_=bytes_,
153154
show_locals=session.config["show_locals"],
155+
console_options=console.options,
154156
)
155157

156158

157-
def _unserialize_and_execute_task(bytes_, show_locals):
159+
def _unserialize_and_execute_task(bytes_, show_locals, console_options):
158160
"""Unserialize and execute task.
159161
160162
This function receives bytes and unpickles them to a task which is them execute
@@ -169,14 +171,16 @@ def _unserialize_and_execute_task(bytes_, show_locals):
169171
task.execute()
170172
except Exception:
171173
exc_info = sys.exc_info()
172-
processed_exc_info = _process_exception(exc_info, show_locals)
174+
processed_exc_info = _process_exception(exc_info, show_locals, console_options)
173175
return processed_exc_info
174176

175177

176-
def _process_exception(exc_info: Tuple[Any], show_locals: bool) -> Tuple[Any]:
178+
def _process_exception(
179+
exc_info: Tuple[Any], show_locals: bool, console_options: ConsoleOptions
180+
) -> Tuple[Any]:
177181
exc_info = remove_internal_traceback_frames_from_exc_info(exc_info)
178182
traceback = Traceback.from_exception(*exc_info, show_locals=show_locals)
179-
segments = console.render(traceback)
183+
segments = console.render(traceback, options=console_options)
180184
text = "".join(segment.text for segment in segments)
181185
return *exc_info[:2], text
182186

0 commit comments

Comments
 (0)