mirror of
https://github.com/wassname/ray.git
synced 2026-07-08 14:56:07 +08:00
Fix passing empty bytes in python tasks (#7045)
* ensure data_ won't be null_ptr when size == 0 * when data_sizes[i] == 0, we should Allocate an empty buffer * work around for pyarrow.py_buffer * fix comments * add null ptr check * add test for bytes * lint
This commit is contained in:
@@ -566,10 +566,13 @@ cdef write_serialized_object(
|
||||
from ray.serialization import Pickle5SerializedObject, RawSerializedObject
|
||||
|
||||
if isinstance(serialized_object, RawSerializedObject):
|
||||
buffer = Buffer.make(buf)
|
||||
stream = pyarrow.FixedSizeBufferWriter(pyarrow.py_buffer(buffer))
|
||||
stream.set_memcopy_threads(MEMCOPY_THREADS)
|
||||
stream.write(pyarrow.py_buffer(serialized_object.value))
|
||||
if buf.get() != NULL and buf.get().Size() > 0:
|
||||
buffer = Buffer.make(buf)
|
||||
# `Buffer` has a nullptr buffer underlying if size is 0,
|
||||
# which will cause `pyarrow.py_buffer` crash
|
||||
stream = pyarrow.FixedSizeBufferWriter(pyarrow.py_buffer(buffer))
|
||||
stream.set_memcopy_threads(MEMCOPY_THREADS)
|
||||
stream.write(pyarrow.py_buffer(serialized_object.value))
|
||||
elif isinstance(serialized_object, Pickle5SerializedObject):
|
||||
(<Pickle5Writer>serialized_object.writer).write_to(
|
||||
serialized_object.inband, buf, MEMCOPY_THREADS)
|
||||
|
||||
@@ -43,6 +43,8 @@ def test_simple_serialization(ray_start_regular):
|
||||
0.9,
|
||||
1 << 62,
|
||||
1 << 999,
|
||||
b"",
|
||||
b"a",
|
||||
"a",
|
||||
string.printable,
|
||||
"\u262F",
|
||||
|
||||
Reference in New Issue
Block a user