mirror of
https://github.com/capnproto/pycapnp.git
synced 2025-03-04 08:24:43 +01:00
Bugfix: Attach server to on_disconnect to prevent early closing
This commit is contained in:
parent
7a8175ed84
commit
770be41b6d
5 changed files with 6 additions and 9 deletions
|
@ -2241,7 +2241,8 @@ cdef class TwoPartyServer:
|
|||
return _CapabilityClient()._init(helpers.bootstrapHelperServer(deref(self.thisptr)), self)
|
||||
|
||||
cpdef on_disconnect(self) except +reraise_kj_exception:
|
||||
return self._network.on_disconnect()
|
||||
return _voidpromise_to_asyncio(deref(self._network.thisptr).onDisconnect()
|
||||
.attach(capnp.heap[PyRefCounter](<PyObject*>self)))
|
||||
|
||||
|
||||
cdef class _AsyncIoStream:
|
||||
|
|
|
@ -110,8 +110,7 @@ class CalculatorImpl(calculator_capnp.Calculator.Server):
|
|||
|
||||
|
||||
async def new_connection(stream):
|
||||
server = capnp.TwoPartyServer(stream, bootstrap=CalculatorImpl())
|
||||
await server.on_disconnect()
|
||||
await capnp.TwoPartyServer(stream, bootstrap=CalculatorImpl()).on_disconnect()
|
||||
|
||||
|
||||
def parse_args():
|
||||
|
|
|
@ -25,8 +25,7 @@ class ExampleImpl(thread_capnp.Example.Server):
|
|||
|
||||
|
||||
async def new_connection(stream):
|
||||
server = capnp.TwoPartyServer(stream, bootstrap=ExampleImpl())
|
||||
await server.on_disconnect()
|
||||
await capnp.TwoPartyServer(stream, bootstrap=ExampleImpl()).on_disconnect()
|
||||
|
||||
|
||||
def parse_args():
|
||||
|
|
|
@ -125,8 +125,7 @@ def parse_args():
|
|||
|
||||
|
||||
async def new_connection(stream):
|
||||
server = capnp.TwoPartyServer(stream, bootstrap=CalculatorImpl())
|
||||
await server.on_disconnect()
|
||||
await capnp.TwoPartyServer(stream, bootstrap=CalculatorImpl()).on_disconnect()
|
||||
|
||||
|
||||
async def main():
|
||||
|
|
|
@ -33,8 +33,7 @@ class ExampleImpl(thread_capnp.Example.Server):
|
|||
|
||||
|
||||
async def new_connection(stream):
|
||||
server = capnp.TwoPartyServer(stream, bootstrap=ExampleImpl())
|
||||
await server.on_disconnect()
|
||||
await capnp.TwoPartyServer(stream, bootstrap=ExampleImpl()).on_disconnect()
|
||||
|
||||
|
||||
def parse_args():
|
||||
|
|
Loading…
Add table
Reference in a new issue