Skip to content

Commit 00d333b

Browse files
timsaucerclaude
andcommitted
docs: convert sender-ctx example to executable doctest
Replace the code-block in the ipc module docstring that demonstrated set_sender_ctx with a doctest that actually runs. Worker-init example remains a code-block since it documents a Pool-initializer pattern that does not fit naturally into a doctest. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e02357b commit 00d333b

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

python/datafusion/ipc.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ def init_worker():
5959
:meth:`SessionContext.with_python_udf_inlining` to every pickled
6060
expression on this thread:
6161
62-
.. code-block:: python
63-
64-
from datafusion import SessionContext
65-
from datafusion.ipc import clear_sender_ctx, set_sender_ctx
66-
67-
driver_ctx = SessionContext().with_python_udf_inlining(enabled=False)
68-
set_sender_ctx(driver_ctx)
69-
try:
70-
pickle.dumps(expr) # encoded with inlining disabled
71-
finally:
72-
clear_sender_ctx()
62+
>>> import pickle
63+
>>> from datafusion import SessionContext, col, lit
64+
>>> from datafusion.ipc import clear_sender_ctx, set_sender_ctx
65+
>>> driver_ctx = SessionContext().with_python_udf_inlining(enabled=False)
66+
>>> set_sender_ctx(driver_ctx)
67+
>>> try:
68+
... blob = pickle.dumps(col("a") + lit(1))
69+
... finally:
70+
... clear_sender_ctx()
71+
>>> isinstance(blob, bytes)
72+
True
7373
7474
Without a sender context the default codec is used (Python UDF
7575
inlining on). The sender context only affects pickle / ``to_bytes``

0 commit comments

Comments
 (0)