You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Bryan Cutler (JIRA)" <ji...@apache.org> on 2017/04/14 17:06:41 UTC
[jira] [Commented] (ARROW-822) [Python] StreamWriter fails to open
with socket as sink
[ https://issues.apache.org/jira/browse/ARROW-822?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15969255#comment-15969255 ]
Bryan Cutler commented on ARROW-822:
------------------------------------
Some code to reproduce, if needed
{noformat}
import pyarrow as pa
import socket, os, io
port = 8080
for res in socket.getaddrinfo("localhost", port, socket.AF_UNSPEC, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
sock = socket.socket(af, socktype, proto)
try:
sock.settimeout(3)
sock.connect(sa)
except socket.error:
sock.close()
sock = None
continue
break
if not sock:
raise Exception("could not open socket")
#sink = socket
sink = sock.makefile("wb", 65536)
#sink = os.fdopen(sock.fileno(), "wb", 65536)
#sink = os.fdopen(os.dup(sock.fileno()), "wb", 65536)
field = pa.Field.from_py("f1", pa.float32())
schema = pa.Schema.from_fields([field])
writer = pa.StreamWriter(sink, schema)
{noformat}
> [Python] StreamWriter fails to open with socket as sink
> -------------------------------------------------------
>
> Key: ARROW-822
> URL: https://issues.apache.org/jira/browse/ARROW-822
> Project: Apache Arrow
> Issue Type: Bug
> Reporter: Bryan Cutler
>
> Trying to use pyarrow StreamWriter to write to a socket fails. I've tried the following:
> - Use socket directly and get "TypeError: Unable to read from object of type: <class 'socket._socketobject'>"
> looks like pyarrow expects the object to have a "write" attribute
> - Using as a file object with: "sock.makefile("wb", 65536)" get the error "pyarrow.error.ArrowIOError: IOError: '_fileobject' object has no attribute 'tell'"
> Not sure why exactly "tell" is required.
> - using "os.fdopen(sock.fileno(), "wb", 65536)" get a rather cryptic error that I've been unable to track down:
> "terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_M_construct null not valid"
> Seems to indicate some kind of std::string construction with a NULL, but I can't find that anywhere
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)