Adding poll_once() to TwoPartyServer API

- poll_forever() doesn't allow for checking socket connection to client
  * Need to check for client, if eof received then we can close the
  connection and cleanup pycapnp cpu resources (async tasks)
- Updated async examples to fix bugs
  * Add checking code for socket connection to the client and gracefully
  cleanup resources once the client socket connection closes
  * Instanciate a new TwoPartyServer per connection (allows for multiple
  connections)
- Should resolve Issue #198
This commit is contained in:
Jacob Alexander
2020-01-08 18:06:26 -08:00
parent ea0858352b
commit dd3551f978
4 changed files with 211 additions and 69 deletions

View File

@@ -2406,6 +2406,9 @@ cdef class TwoPartyServer:
cpdef on_disconnect(self) except +reraise_kj_exception:
return _VoidPromise()._init(deref(self._network.thisptr).onDisconnect())
def poll_once(self):
return poll_once()
async def poll_forever(self):
while True:
poll_once()