no23reason opened a new issue, #34415:
URL: https://github.com/apache/arrow/issues/34415

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   When implementing a custom `do_put` operation using `FlightServerBase`, if 
the client does not call `done_writing()` on its writer before trying to read 
metadata sent from the server, both client and server hang and need to be 
killed.
   
   Is the `done_writing()` required by design? In other words does the process 
always need to be
   1. client writes all of its data
   2. client calls `done_writing()`
   3. client reads the metadata server sent back
   
   Or is this a bug?
   
   server.py
   ```python
   import pyarrow as pa
   import pyarrow.flight as flight
   
   
   class Server(flight.FlightServerBase):
       def __init__(self, location):
           super(Server, self).__init__(location=location)
   
       def do_put(self, context, descriptor, reader, writer):
           for batch in reader:
               print(f"got batch {str(batch.data)}")
           # or even just reader.read_all()
   
           print("sending metadata back")
           writer.write(pa.py_buffer((42).to_bytes(8, byteorder="big")))
   
   
   def main():
       server = Server("grpc://localhost:16661")
       server.serve()
   
   
   if __name__ == "__main__":
       main()
   ```
   
   client.py
   ```python
   import pandas as pd
   import pyarrow as pa
   import pyarrow.flight as flight
   
   
   def main():
       print("starting")
       client = flight.connect("grpc://localhost:16661")
       df = pd.DataFrame(
           {
               "n_legs": [None, 4, 5, None],
               "animals": ["Flamingo", "Horse", None, "Centipede"],
           }
       )
       table = pa.Table.from_pandas(df)
   
       writer, reader = client.do_put(
           flight.FlightDescriptor.for_path(b"fun/times"), table.schema
       )
   
       writer.write_table(table)
   
       print("done putting")
       # if this line is uncommented, everything starts working fine
       # writer.done_writing()
   
       meta = reader.read()
       print(int.from_bytes(meta))
   
   
   if __name__ == "__main__":
       main()
   
   ```
   
   ### Component(s)
   
   Python


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to