Search code examples
c#rpcthrift

Propper way to stop a thrift TThreadPoolAsyncServer in .net standard


I've created a TThreadPoolAsyncServer witch is working correctly.

_server = new TThreadPoolAsyncServer(
                 processorFactory: new TSingletonProcessorFactory( processor ),
                 serverTransport: serverSocket,
                 inputTransportFactory: new TFramedTransport.Factory(),
                 outputTransportFactory: new TFramedTransport.Factory(),
                 inputProtocolFactory: new TBinaryProtocol.Factory(),
                 outputProtocolFactory: new TBinaryProtocol.Factory(),
                 threadConfig: new TThreadPoolAsyncServer.Configuration(),
                 logger: _logger );

But when I trigger the cancelationtoken from _server.ServeAsync( cancellationtoken );, the task does not complete. When I use the _server.Stop(); function the server eventually stops but the server also logs some not so nice looking errors:

      Thrift.Transport.TTransportException: System.ObjectDisposedException: Cannot access a disposed 

What is the intended way to stop the TThreadPoolAsyncServer?


Solution

  • For anyone else who stumbles upon this, this will be fixed in version 15. https://issues.apache.org/jira/browse/THRIFT-5398