Commit graph

278 commits

Author SHA1 Message Date
Jacob Alexander
75e0e7e84c
Fixed or waved all pytest failures and errors
- Needed to include cleanup_global_schema_parser() to handle duplicate
imports of the same .capnp file
  * Duplicate IDs are a problem as pytest does not fully cleanup between
  tests
- Marked some tests as xfail as I'm not sure the test is supposed to
work anymore with recent versions of capnproto
2019-09-27 01:12:54 -07:00
Jacob Alexander
b3021e4f6b
Fixing flake8 warnings and errors
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude benchmark

Excluding the benchmark directory (due to protobuf generated files)
Also removing some Python2 specific code
2019-09-27 00:15:13 -07:00
Jacob Alexander
8915ef79f1
TwoWayPipe and basic asyncio support
Note: I've tried not to break any behaviour of the previously working APIs

Python API Changes / Additions
- capnp/lib/capnp.pyx
  * class _RemotePromise
    + [Added] cpdef _wait(self)
      = Exception raising code that used to be inside of wait(self)
    + [Modified] def wait(self)
      = Same functionality as before
    + [Added] async def a_wait(self)
      = Cannot use await as that's a reserved keyword
      = Uses pollRemote and asyncio.sleep(0) to make call asynchronous
  * class _TwoPartyVatNetwork
    + [Added] cdef _init_pipe(self, _TwoWayPipe pipe, Side side,
    schema_cpp.ReaderOptions opts)
      = Instanciates a TwoPartyVatNetwork using a TwoWayPipe (instead of
      using a file handle or connection as before)
  * class TwoPartyClient
    + [Modified] def __init__(self, socket=None, restorer=None,
    traversal_limit_in_words=None, nesting_limit=None)
      = Changes the socket parameter to be optional
      = If socket is not specified, default to using a TwoWayPipe
    + [Added] async def read(self, bufsize)
      = awaitable function that blocks until data has been read
      = bufsize defines the maximum amount of data to be read back
        (e.g. 4096 bytes)
      = Reads data from TwoWayPipe
    + [Added] def write(self, data)
      = Write data to TwoWayPipe
      = Not awaitable as the write interface of the TwoWayPipe doesn't
      have poll functionality
  * class TwoPartyServer
    + [Modified] def __init__(self, socket=None, restorer=None,
    server_socket=None, bootstrap=None, traversal_limit_in_words=None,
    nesting_limit=None)
      = Changes the socket parameter to be optional
      = If socket is not specified, default to using a TwoWayPipe
      = Simplified code by removing an else (self._connect)
    + [Added] async def read(self, bufsize)
      = awaitable function that blocks until data has been read
      = bufsize defines the maximum amount of data to be read back
        (e.g. 4096 bytes)
      = Reads data from TwoWayPipe
    + [Added] def write(self, data)
      = Write data to TwoWayPipe
      = Not awaitable as the write interface of the TwoWayPipe doesn't
      have poll functionality
    + [Added] async def poll_forever(self)
      = asyncio equivalent of run_forever()
  * class _TwoWayPipe
    + Wrapper class for TwoWayPipe

Other Additions
- capnp/helpers/asyncHelper.h
  * pollWaitScope
    + Pumps the kj event handler
    + Used for the TwoWayServer
  * pollRemote
    + Polls a remote promise
    + i.e. a capnp RPC call
- capnp/helpers/asyncIoHelper.h
  * AsyncIoStreamReadHelper
    + I wasn't able to figure out Promise[size_t] using Cython so this was
    the next best thing I could think of doing
    + Was needed to handle read polling from a read promise
      = Polling is used for asyncio as kj waits need a wrapper to be
      compatible
- capnp/lib/capnp.pyx
  * makeTwoWayPipe
    + Wrapper for kj newTwoWayPipe function
  * poll_once
    + Single pump of the kj event handler (used with pollWaitScope)

TwoWayClient Usage - TwoWayPipe
- See examples/async_client.py

TwoWayServer Usage - TwoWayPipe
- See examples/async_server.py

capnp/helpers/asyncIoHelper.h

Misc Changes
- Fixed thread_server.py and thread_client.py to use bootstrap instead
of ez_restore
- async_client.py and async_server.py examples
  * Uses the same thread.capnp as thread_client.py and thread_server.py
  * They are compatible, so you can mix and match client and server for
  compatibility testing
  * async_client.py and async_server.py require <address>:<port>
  formatting (unlike autodetection from thread_client.py and
  thread_server.py)
2019-09-26 21:42:48 -07:00
Jacob Alexander
e73b63ddd1
Removed deprecated functions
- PyObject_AsReadBuffer
- PyObject_AsWriteBuffer
2019-09-16 21:37:00 -07:00
Andrey Cizov
e8662a1dc9
remove deprecation warnings 2019-09-16 21:34:58 -07:00
Andrey Cizov
423e4f1f8c
remove warning during compilation 2019-09-16 21:34:58 -07:00
Jacob Alexander
de22f7eb97
Fixing compilation errors with capnproto-7.0.0 2019-09-16 21:33:56 -07:00
Trevor Highland
dbd23721a9 Support long messages in read_multiple_bytes. 2019-01-28 17:04:34 +00:00
Colin Jermain
eb62693915 Exposing SchemaParser in Cython header 2018-11-06 21:11:59 -05:00
Yuval Katsnelson
a73395e7bb Fixed Python object leak in RemotePromise 2017-12-06 10:48:38 +02:00
Ivan Smirnov
18e87a1719 (Remove now-redundant import) 2017-11-28 00:19:15 +00:00
Ivan Smirnov
6a5f697f72 Support generic buffers in from_bytes()
(Also throw a TypeError if it's not a bytes object or a buffer)
2017-11-28 00:18:20 +00:00
Jason Paryani
2566bbc84c Merge pull request #154 from benmoran/capnproto-0.6.0
Capnproto 0.6.0
2017-07-27 17:41:52 -07:00
Trevor Highland
4435c60872 Issue 145: decrement exception object prior to returning. 2017-07-26 20:17:52 -05:00
Ben Moran
fbc1767475 Expose Duration units and add a Nanoseconds function to let us build against 0.6.0 2017-06-08 12:01:11 +01:00
Jason Paryani
073a503add Merge pull request #136 from ternaris/lists-from-tuples
support initializing DynamicListBuilder from tuple
2017-04-09 17:36:35 -07:00
Jason Paryani
3f04134e72 Merge pull request #139 from tundra/develop
Pass options correctly through from_bytes to FlatArrayMessageReader
2017-04-09 17:11:20 -07:00
Jason Paryani
5eec70231a Merge pull request #126 from asilversempirical/pass_reader_opts_clean
Let TwoParty Clients and Servers take ReaderOptions
2017-04-09 16:52:36 -07:00
Christian Plesner Hansen
34385afbbd Pass options correctly through from_bytes to FlatArrayMessageReader 2017-02-15 12:02:41 +01:00
Florian Friesdorf
1bfc20fefb support initializing DynamicListBuilder from tuple 2017-02-09 02:16:25 +01:00
Alex Silverstein
0382beb26a Let TwoParty Clients and Servers take ReaderOptions 2017-01-22 02:25:58 +00:00
Florian Friesdorf
f2c7f61b7d include class attributes in __dir__
This enables tab completion for methods as well as fieldnames.
2017-01-20 11:00:11 +01:00
Madeleine Thompson
93ea35e558 make enums hashable 2016-12-05 22:43:09 -05:00
Jason Paryani
97824b957b Add clear_write_flag method to builders
Fixes #111
2016-08-09 12:26:18 -07:00
Jason Paryani
d85200cee3 Remove recursive loop in KjException.type
Fixes #108
2016-07-29 11:59:02 -07:00
Jason Paryani
4488194f59 Make event loop be lazy initialized for real 2016-07-29 11:57:19 -07:00
Jason Paryani
da233c46ad Make the event loop be lazy initialized
Fixes #101
2016-07-07 12:11:42 -07:00
Constantine Vetoshev
41c418aa1c Use PyObject_AsReadBuffer instead of bytes(). 2016-06-24 16:43:57 -07:00
Constantine Vetoshev
e8a8d26260 Fix memory leak. 2016-06-24 14:03:20 -07:00
Constantine Vetoshev
fb8a3d8ac2 Add docstrings to (de)serialization functions. 2016-06-24 13:28:26 -07:00
Constantine Vetoshev
70e4e2d930 Add ReaderOptions support to segment (de)serialization. 2016-06-24 13:25:27 -07:00
Constantine Vetoshev
09705b6d1f Add support for segment (de)serialization. 2016-06-23 14:32:18 -07:00
Jason Paryani
5ffe7eb2f6 Fix response objects not referencing parents correctly
Fixes #103
2016-06-17 13:50:42 -07:00
Jason Paryani
589400f53a Fix build problem with Cython v0.24
Fixes #97
2016-05-27 13:53:09 -07:00
Mike Lundy
7164f04a7c Eliminate outdated function 2016-03-04 13:52:14 -08:00
Mike Lundy
302fc64041 Include the traceback in exceptions
This makes debugging into the cython side of the code much easier.
2016-03-04 13:52:14 -08:00
Mike Lundy
8c3c57aa32 Make sure to encode to utf-8, not the default encoding
This allows text fields to take unicode strings under python 2.
2016-03-04 13:50:43 -08:00
Jason Paryani
2be308db27 Throw an exception on invalid BufferView instantiation
Also adjust tests to skip mmap under Python 2.
2016-03-04 12:42:45 -08:00
Benjamin Piwowarski
b7a9d05e5e Support mmap objects for reading with from_bytes 2016-02-05 17:32:40 +01:00
Jason Paryani
2516e3e4f1 Change read_multiple and read_multiple_packed to copy by default
Add a `skip_copy` paramter for people that know what they're doing and
need higher performance.

Fixes #87
2015-12-04 16:31:26 -08:00
Jason Paryani
b863e9b9d6 Fix mistakenly discarding the file parameter on reads
Fixes #82
2015-12-04 16:01:28 -08:00
Klee Dienes
8436a1908d Add reraise_kj_exception to the prettyPrint functions. 2015-11-14 18:51:20 -05:00
Sergei Dyshel
4e6f381855 Fix KjException init (missing wrapper). 2015-10-21 15:11:43 +03:00
Jason Paryani
3357771b39 Fixes for changes in cython v0.22.1 2015-07-13 10:57:55 -07:00
Jason Paryani
b57f0f0df8 Add result_type to InterfaceMethodSchema 2015-07-12 12:21:29 -07:00
Jason Paryani
bd0576b68a Add warnings for using old restorer methods 2015-06-16 11:47:13 -07:00
Jason Paryani
819f21938e Fix warning from PyEventPort 2015-06-16 11:28:18 -07:00
Jason Paryani
a4990f0868 Handle AnyPointers better as arguments to RPC functions 2015-06-08 14:59:21 -07:00
Jason Paryani
6f1ce8bcc5 Add support for using keyword arguments with a named struct in an RPC 2015-06-08 13:39:10 -07:00
Jason Paryani
7ff67ebf4a Add bootstrap method to TwoPartyServer 2015-06-04 16:49:46 -07:00