Commit graph

661 commits

Author SHA1 Message Date
Jacob Alexander
78776de647
Adding examples as pytest tests
- This way they will be included in CI checks
- Decreased the delay time in the thread-like examples to speed up tests
(probably could decrease the time some more)
- Added an async version of the calculator test
- Forcing python3 support for example scripts
2019-09-27 14:40:54 -07:00
Jacob Alexander
58a5c5fc1f
Initial pythonpackage.yml for GitHub Actions 2019-09-27 01:52:41 -07:00
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
d62e9b80f7
Always use Cython 2019-09-27 00:30:08 -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
1f0200af9c
Unlocking python package version requirements 2019-09-26 21:54:12 -07:00
Jacob Alexander
db4e567c6b
Upgrading to capnproto-0.7.0
- Needed for asyncio support
2019-09-26 21:42:55 -07:00
Jacob Alexander
1a127bec6f
Adding pure python SSL test using asyncio
- Uses thread.capnp
- Follows same format as thread_client.py/thread_server.py and
async_client.py/async_server.py
- Including a basic self signed certificate for testing convenience
- Python 3.7 has a bug cleaning up SSL when using asyncio.run
  https://bugs.python.org/issue36709
  Have a slightly more verbose workaround to do proper cleanup
2019-09-26 21:42:54 -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
33725b9e7f
ignore files created during setup.py install 2019-09-16 21:34:58 -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
Colin Jermain
bc1a3a5f3f
Merge pull request #185 from andreycizov/fix-travis-build
fix travis build failure
2019-07-15 19:43:08 -04:00
Andrey Cizov
ab267eccbd fix travis build failure 2019-07-13 15:06:18 +01:00
Jason Paryani
cb3f190b95 Add deploy notes about tags 2019-02-01 15:11:53 -08:00
Jason Paryani
3ab199b4b9 Fix minor typo in Changelog 2019-01-31 01:30:07 -08:00
Jason Paryani
bdb7d101e9 Add DEPLOY.md with instructions for deploying to PyPI 2019-01-31 01:20:29 -08:00
Jason Paryani
a4f740fb0f Bump version to v0.6.4 and update changelog 2019-01-31 01:10:15 -08:00
Jason Paryani
e4d7e21a66 Add error if trying to run python setup.py sdist without pandoc 2019-01-31 01:03:21 -08:00
Jason Paryani
da8f8869fc Add some edge case tests for read_multiple_bytes 2019-01-31 01:02:11 -08:00
Colin Jermain
29e63de41d
Merge pull request #179 from tsh56/bugfix/issue-178
Support long messages in read_multiple_bytes.
2019-01-28 18:50:47 -05:00
Trevor Highland
2a66c2f6bf Skip tests based on python version. 2019-01-28 18:09:17 +00:00
Trevor Highland
ed6e39ded0 Update test to support 3.5 2019-01-28 17:39:10 +00:00
Trevor Highland
dbd23721a9 Support long messages in read_multiple_bytes. 2019-01-28 17:04:34 +00:00
Colin Jermain
adfc76f4c2
Merge pull request #175 from cjermain/feature/schema-parser-header
Exposing SchemaParser in Cython header
2019-01-15 19:19:58 -05:00
Colin Jermain
ddb0bc9306 Merge branch 'develop' into feature/schema-parser-header 2019-01-14 20:11:55 -05:00
Colin Jermain
59fdf948a6
Merge pull request #176 from cjermain/bug/fix-python-versions
Replacing end-of-life Python versions with live versions
2019-01-14 20:07:43 -05:00
Colin Jermain
2b26665f56 Removing Python 3.7 from this PR 2018-11-18 16:27:09 -05:00
Colin Jermain
afe72a15b1 Setting distro to Xenial globally in attempt to get Python 3.7 CI 2018-11-18 15:39:33 -05:00
Colin Jermain
7052cdbaba Removing Python 3.7 from normal Travis Python list 2018-11-18 10:52:58 -05:00
Colin Jermain
770896132b Adding patch to Travis CI for Python 3.7 support 2018-11-18 10:35:57 -05:00
Colin Jermain
3afcbb3918 Replacing end-of-life Python versions with live versions 2018-11-18 10:01:10 -05:00
Colin Jermain
eb62693915 Exposing SchemaParser in Cython header 2018-11-06 21:11:59 -05:00
Jason Paryani
19e1b189ca Bump version to v0.6.3 and update changelog 2018-01-14 11:57:08 -08:00
Jason Paryani
1665f9003f
Merge pull request #164 from E8-Storage/develop
Capnproto 0.6.1 and one less memory leak
2018-01-14 11:50:45 -08:00
Yuval Katsnelson
74618de3ef Update bundled capnp to 0.6.1 2017-12-06 10:49:09 +02:00
Yuval Katsnelson
a73395e7bb Fixed Python object leak in RemotePromise 2017-12-06 10:48:38 +02:00
Jason Paryani
add8af4bc9 Bump version to v0.6.2 and update changelog 2017-11-30 22:08:01 -08:00
Jason Paryani
6831626a8e Merge branch 'develop' of github.com:jparyani/pycapnp into develop 2017-11-30 22:05:33 -08:00
Jason Paryani
0dcc171acc
Merge pull request #163 from aldanor/feature/from-bytes-buffer
Support generic buffers in from_bytes()
2017-11-30 11:16:46 -08:00
Ivan Smirnov
18e87a1719 (Remove now-redundant import) 2017-11-28 00:19:15 +00:00
Ivan Smirnov
8fd6cc6f66 Add a test for generic from_bytes() 2017-11-28 00:18:20 +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
0242ba2d33 Bump to v0.6.1 and update changelog 2017-07-27 20:11:49 -07:00
Jason Paryani
b3ab9ab2a6 Update changelog for v0.6.0 2017-07-27 19:59:54 -07: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
Jason Paryani
bb457432f7 Merge pull request #158 from tsh56/develop
Closes #145: decrement exception object prior to returning.
2017-07-27 17:31:36 -07:00
Trevor Highland
4435c60872 Issue 145: decrement exception object prior to returning. 2017-07-26 20:17:52 -05:00