Commit Graph

2297 Commits

Author SHA1 Message Date
Lidi Zheng 087d48a8bd Update the documentation about the status code constraint 2018-12-12 14:31:52 -08:00
Lidi Zheng fd74fcf2a0 New abort with grpc.Status API
* Add `abort_with_status` method in ServicerContext
* Add `Status` interface similar to the design of Details in interceptor
* Add 3 unit test cases for abort mechanism
2018-12-12 13:48:39 -08:00
Richard Belleville e829a81118
Merge pull request #17460 from grpc/enable-census
Add hooks for census context propagation
2018-12-11 14:49:19 -08:00
Richard Belleville 6b3baf2618 Add hooks for census context propagation
Appease the yapf gods

Reformat
2018-12-11 12:59:31 -08:00
Noah Eisen 9e9cae7839
Merge pull request #17456 from ncteisen/socket-pagination
Channelz: Add Pagination to ServerSockets
2018-12-11 12:27:49 -08:00
ncteisen 7b1fc0faa2 Add max_results to ServerSockets 2018-12-11 08:24:40 -08:00
Mark D. Roth c5f344deaf
Revert "Revert "Allow encoding arbitrary channel args on a per-address basis."" 2018-12-11 07:48:14 -08:00
Lidi Zheng 8cb2d0546d Upgrade sanity Docker image to debian:stretch
* Use latest pylint in Python 3.7 (they dropped support for PY2)
* Make latest pylint happy
* Forced to upgrade to shellcheck 0.4.4
* Make shellcheck 0.4.4 happy
* Adopt reviewers' advice to reduce global disabled rules
2018-12-10 16:21:49 -08:00
hcaseyal 936512fe02
Merge pull request #17450 from grpc/revert-17343-server_address_list
Revert "Allow encoding arbitrary channel args on a per-address basis."
2018-12-07 17:31:18 -08:00
Lidi Zheng 64fc25f38c
Merge pull request #17411 from lidizheng/add-license
Add License to Python tarball
2018-12-07 16:49:52 -08:00
hcaseyal 27e2ba31bf
Revert "Allow encoding arbitrary channel args on a per-address basis." 2018-12-07 16:13:37 -08:00
Mark D. Roth dedff37b4f Allow encoding arbitrary channel args on a per-address basis. 2018-12-07 12:41:51 -08:00
Eric Gribkoff d74a6b1860
Merge pull request #17410 from ericgribkoff/channelz_stop_server
stop() server and enable skipped channelz test
2018-12-07 09:19:27 -08:00
Eric Gribkoff a324bcaad0 Pre-fix python3 pylint failures 2018-12-06 14:51:00 -08:00
Lidi Zheng 5584d58e6c Add LICENSE to grpcio-* packages
* Using the proprocess command to copy the LICENSE
2018-12-05 15:25:48 -08:00
Eric Gribkoff 9dce850250 stop() server and enable skipped channelz test 2018-12-05 11:48:17 -08:00
Eric Gribkoff 8998dfcb7a
Merge pull request #17396 from ericgribkoff/creds_close_hang
credentials: call grpc_init/grpc_shutdown when created/destroyed
2018-12-04 18:31:45 -08:00
Eric Gribkoff e699c47c1e credentials: call grpc_init/grpc_shutdown when created/destroyed
This addresses https://github.com/grpc/grpc/issues/17001. Prior to
https://github.com/grpc/grpc/pull/13603, our credentials cython objects
used grpc_initi() and grpc_shutdown() on creation and destruction. These are
now managed differently, but the grpc_init() and grpc_shutdown() calls
are still required. See the MetadataCredentialsPluginWrapper in C++,
which extends the GrpcLibraryCodegen class to ensure that grpc_init()
and grpc_shutdown() are called appropriately.

Without this, we can deadlock when a call to grpc.Channel#close()
triggers grpc_shutdown() to block and wait for all timer threads to
finish: one of these timer threads may end up unreffing the subchannel
and triggering grpc_call_credentials_unref, which will jump back into
Cython and hang when it tries to reacquire the GIL.
2018-12-04 14:29:04 -08:00
Lidi Zheng c339ba3229
Merge pull request #16971 from lidizheng/surface-exceptions
Surface exceptions from Cython to Python as much as possible
Fixed #16643
2018-12-03 16:42:13 -08:00
Lidi Zheng 7ef8fc826c
Merge pull request #17266 from lidizheng/python-channelz
Channelz Python wrapper implementation
2018-11-29 16:10:32 -08:00
Lidi Zheng 69b6c047bc Update docstring of Channelz function && add default variable initialization 2018-11-29 12:57:00 -08:00
Lidi Zheng 8e3234963e Update comments && modify function name 2018-11-29 11:29:43 -08:00
Eric Gribkoff 3a47e2c41d
Merge pull request #17307 from ericgribkoff/create_server_format
fix docstring on grpc.server
2018-11-29 09:40:03 -08:00
Lidi Zheng 7eddafabdd Disable three subchannel unit tests for gevent 2018-11-28 17:15:42 -08:00
Lidi Zheng 99f248ae12 Remove the `del` hack and skip server related test cases 2018-11-28 14:49:28 -08:00
Lidi Zheng d75abb6663 Adding comment about `del` about #17258 2018-11-28 14:32:36 -08:00
Eric Gribkoff d9f656a911 fix docstring on grpc.server 2018-11-28 11:13:06 -08:00
Lidi Zheng 53476eced4 Adopt reviewer's suggestions
* Correct the StatusCode
* Format code
* Use @staticmethod
* Fix typo
2018-11-28 10:30:39 -08:00
Mehrdad Afshari 8199aff7a6 Fix Python blocking interceptors facing RpcError
RpcError should be returned from the continuation intact,
not raised.
2018-11-28 00:53:46 -08:00
Lidi Zheng 43599facf4 Channelz Python wrapper implementation
* Expose the C-Core API in Cython layer
* Handle the object translation
* Create a separate package for Channelz specifically
* Handle nullptr and raise exception if seen one
* Translate C++ Channelz unit tests
* Adding 5 more invalid query unit tests

Adding peripheral utility for grpcio-channelz package
* Add to `pylint_code.sh`
* Add to Python build script
* Add to artifact build script
* Add to Bazel
* Add to Sphinx module list
2018-11-27 17:27:39 -08:00
Lidi Zheng 3adca9ff93 Surface exceptions from Cython to Python as much as possible 2018-11-27 12:11:09 -08:00
Ruslan Nigmatullin f8f711ae4c [cython] Declare symbols once 2018-11-26 22:12:16 -08:00
Lidi Zheng 4bc98acfd7
Merge pull request #17281 from lidizheng/issue-16718
Raise the exception while credential initialization
2018-11-26 10:35:20 -08:00
Lidi Zheng b7fd18daa4 Raise the exception while credential initialization 2018-11-26 10:15:14 -08:00
Jan Tattermusch 346d745c6e
Merge pull request #15640 from jtattermusch/slow_python_interop_build
Run interop tests using python3.4 (and build interop with 3.4 only)
2018-11-26 09:38:05 +01:00
Lidi Zheng e0d9692fa3
Merge pull request #17268 from mehrdada/remove-beta-elements-from-bazel
Remove beta module dependency from the Python Bazel package
2018-11-21 15:56:50 -08:00
Mehrdad Afshari e69c1b960f Remove BUILD.bazel files from beta code elements
Beta code elements are going to get deprecated and
Bazel support is much newer, so Bazel users are
not supposed to accidentally depend on beta code
elements.  Preventing Bazel from building and
including beta code elements makes our tests pass
without depending on beta in grpcio target and
helps avoid including that dependency accidentally
if you are using Bazel.
2018-11-21 13:40:10 -08:00
Mehrdad Afshari 107539c0d7 Removed unused import from grpc.beta in tests 2018-11-21 13:37:02 -08:00
Yash Tibrewal 248e304671 Merge branch 'master' into httpplumbing 2018-11-21 11:48:41 -08:00
Jan Tattermusch b609caebf1 trailing "-bin" metadata is binary 2018-11-21 19:12:15 +01:00
Jan Tattermusch 29f44db128 fix initial->trailing 2018-11-21 19:06:14 +01:00
Jan Tattermusch 95bae1ead9 make client_email loading python3 compatible 2018-11-21 13:08:30 +01:00
Mehrdad Afshari 989af50e1d Remove beta modules from the Python Bazel package 2018-11-21 00:17:25 -08:00
Eric Gribkoff b654c8d279 python: close channels in _server_ssl_cert_config_test 2018-11-20 15:29:02 -08:00
Muxi Yan f3e4ae633e Regenerate projects 2018-11-19 15:24:53 -08:00
Yash Tibrewal fc332d2c92 Merge master 2018-11-16 11:11:04 -08:00
Juanli Shen 8a880801ae Add support for LB config in service config 2018-11-15 13:31:27 -08:00
Yihua Zhang 3fefdde3cc remove ALTS shared resources 2018-11-13 09:44:28 -08:00
Lidi Zheng 9b65b40247 Label wait-for-ready argument in multicallables as experimental 2018-11-12 13:57:59 -08:00
Richard Belleville 27bab0c631
Merge pull request #17143 from grpc/module-root-logger
Only Add NullHandler to Module-Root Logger
2018-11-12 10:12:23 -08:00
Richard Belleville c477cb8597 Add missing transitive dependencies
This commit resolves an interop test currently failing on master. Over
the past couple of weeks, bazel-based tests have been introduced. The
current setup does not appear to automatically handle transitive
dependencies. Instead, transitive dependencies such as `requests` have
been manually added to `requirements.bazel.txt`. It appears that the
build server happened to have the dependencies of the `requests` library
installed already, but later had a configuration wipe.

This was compounded by the google-auth library erroneously reporting
that the `requests` module itself was not installed. In fact, it was the
transitive dependencies of `requests` that were not being installed by
the build file. (third-order dependencies of our test)

I consider this a quick fix to get the build passing. In the long run,
we need to automatically resolve and install transitive dependencies in
our bazel builds.

Resolves: #17170
2018-11-09 16:53:43 -08:00
Richard Belleville ecd9063424 Use single NullHandler for whole library
I was trying to get a feel for what the rest of the python ecosystem
does with its logging, so I looked into the top few libraries on pypi:

urllib3 maintains a logger for not quite every module, but for each
one that does heavy lifting. The logger name is `__name__`, and no
handlers are registered for any module-level loggers, including
NullHandler. Their documentation spells out how to configure logging
for the library.

They explicitly configure a library root-level logger called `urllib3`
to which they attach a `NullHandler`. This addresses the "no handlers
could be found" problem.

Their tests explicitly configure handlers, just like ours do.

scrapy is more hands-on. It provides a configuration module for its
logging and a whole document on how to handle logging with scrapy. It
looks like log.py's whole reason for existence is making sure that a
handler is attached to to the scrapy handler at startup.

I think the extra complexity here is because scrapy also offers a CLI,
so there has to be some way to configure logging without resorting to
writing python, so I felt we didn't need to resort to this added
complexity.

---

Based on all of the libraries I've looked at, I think our current
approach is reasonable. The one change I would make is to explicitly
configure a `grpc` logger and to only attach a `NullHandler` to it
instead of putting the burden on the author of each new module to
configure it there.

With this change, I have

- Configured a logger in each module that cares about logging
- Removed all NullHandlers attached to module-level loggers
- Explicitly configured a `grpc` logger with a `NullHandler` attached

Resolves: #16572
Related: #17064
2018-11-09 08:47:42 -08:00
Lidi Zheng 01c6565fb5
Merge pull request #16995 from lidizheng/from-3.4-to-3.7
Migrate tests from Python 3.4 to Python 3.7
2018-11-07 11:11:02 -08:00
Lidi Zheng 678ea08950
Merge pull request #16919 from lidizheng/wait-for-ready
Add wait-for-ready semantics
2018-11-07 11:10:23 -08:00
Lidi Zheng a7a3f5b42e
Merge pull request #17074 from lidizheng/python-doc-gen
The new gRPC Python documentation generator
2018-11-07 11:08:19 -08:00
Lidi Zheng cabe8d8f10 New Python documentation generation
* Use templates instead of generating them every time
* Theme changed
* Add grpc_* modules
* APIs grouped
* No documentation for class members without docstring
* Add docstring for status code
2018-11-06 18:07:03 -08:00
Lidi Zheng 4821221e3a Add wait-for-ready semantics
* Include unit tests to test default behaviour, disable behaviour, enable behaviour of the wait-for-ready mechanism
* Import flags constants from grpc_types.h
* Use WaitGroup to wait for TRANSIENT_FAILURE state in unit test
2018-11-06 17:16:52 -08:00
Lidi Zheng 88150dbe2c
Merge pull request #17128 from lidizheng/add-comment-to-commands-py
Add background about gRPC Python's building process on macOS
2018-11-06 17:05:55 -08:00
Lidi Zheng 03841be6ce Add background about the special condition 2018-11-06 16:12:27 -08:00
Lidi Zheng 8a0b08b574 Migrate tests from Python 3.4 to Python 3.7 2018-11-06 15:37:51 -08:00
Jan Tattermusch 7517b839ac
Merge pull request #17057 from jtattermusch/faster_python_build
Add python monkey-patch for parallel build_ext compilation
2018-11-06 12:13:18 +01:00
Lidi Zheng 2a1fbccb2c
Merge pull request #16976 from benjaminp/remove-pkg_resources
Replace pkg_resources with pkgutil.
2018-11-05 17:00:46 -08:00
Lidi Zheng b8a9989005 Add support for utf-8 error messages
* Both server and client should be fine with utf-8 error messages now
* Adding an interop test: special status message
2018-11-05 13:31:02 -08:00
yihuaz 5e9c9792b5
Merge pull request #16773 from yihuazhang/alts_tsi_handshaker_use_pollset_set
Use gRPC thread model (i.e., pollset_set) in ALTS TSI implementation
2018-11-02 11:05:54 -07:00
Srini Polavarapu f00af6d1ab
Merge pull request #17081 from nathanielmanistaatgoogle/restore-python-bazel
Restore reverted Python Bazel work
2018-11-02 10:06:10 -07:00
Noah Eisen 53657b5de3
Merge pull request #17050 from ncteisen/channelz-sockets
Channelz: Socket Tracks Addresses
2018-11-01 23:39:51 -04:00
Benjamin Peterson 187f7e4e4c Replace pkg_resources with pkgutil.
pkg_resources (part of setuptools) is overkill for reading resource files. The standard library module pkgutil can do that just fine.
2018-11-01 17:01:12 -07:00
Yihua Zhang cd768ec12a use gRPC thread model 2018-11-01 16:26:46 -07:00
Richard Belleville b741454fe4
Merge pull request #17064 from gnossen/fix-logging
Fix logging
2018-11-01 16:11:28 -07:00
Lidi Zheng f091ba1b66
Merge pull request #17008 from stub42/yay_destructors
Handle missing globals in Python Channel destructors
2018-11-01 14:15:16 -07:00
Richard Belleville 18cc5f5dbe Use custom assertions 2018-11-01 13:29:28 -07:00
Richard Belleville cf624a98e6 Isolate logging in all test cases 2018-11-01 13:24:03 -07:00
Naresh cd931752ca Bazel rules for gRPC Python interop tests
Add interop tests for gRPC Python. py_proto_library rules are added to
src/proto/grpc/testing/BUILD since grpc_proto_library is not compatible
with py_* rules.

'requests' python module is added to requirements.bazel.txt as it is a
dependency for google-auth. Previously, this was installed through
tools/run_tests/helper_scripts/build_python.sh before running tests.
2018-11-01 12:01:02 +00:00
Naresh e4382abc9c Bazel rules for Python grpcio_reflection 2018-11-01 12:01:02 +00:00
ncteisen 44b262c361 fix build and sanity 2018-10-31 21:11:28 -07:00
Richard Belleville dc05e31ff1 Appease the yapf gods 2018-10-31 17:22:30 -07:00
Richard Belleville 78eae493b4 Add explicit test that user can configure their own handler 2018-10-31 17:20:43 -07:00
Richard Belleville fec37654fb Fix splat 2018-10-31 17:04:51 -07:00
Richard Belleville acc72c0835 Format code 2018-10-31 16:47:56 -07:00
Richard Belleville 79d0424468 Pull out function to patch stderr 2018-10-31 16:45:54 -07:00
Richard Belleville b7335f5c01 Add test for 'No handlers could be found' problem 2018-10-31 16:43:36 -07:00
ncteisen 1a3c2d3e3a Move uri_parser to lib 2018-10-31 14:14:09 -07:00
Richard Belleville a3ffca1440 Format code 2018-10-31 11:47:13 -07:00
Richard Belleville db1294dd47 Add logging tests to tests.json 2018-10-31 10:56:29 -07:00
Jan Tattermusch 185a0a7028 add python monkey-patch for parallel build_ext compilation 2018-10-31 09:01:01 +01:00
Richard Belleville 4d086ef0f4 Fix various mind-numbing typos 2018-10-30 18:53:00 -07:00
Richard Belleville fb972c960f Add basicConfig handler to grpcio_testing 2018-10-30 18:44:06 -07:00
Richard Belleville 240ca50ec2 Add basicConfig handler to unit tests 2018-10-30 18:43:18 -07:00
Richard Belleville 839722adc5 Add NullHandler to avoid warnings about no handler 2018-10-30 18:16:53 -07:00
Richard Belleville 1e05d48d2d Revert "Configure module level loggers with basicConfig()"
This reverts commit a20e2073c1.
2018-10-30 17:53:50 -07:00
Richard Belleville ff1c31f47c Add failing unit test 2018-10-30 17:51:15 -07:00
ncteisen 3cb8b0b8cb Move uri_parser to common spot 2018-10-30 11:39:26 -07:00
Lidi Zheng 4e5ee57000 Change flag to `REQUIRE_CUSTOM_LIBRARIES_opt` 2018-10-30 10:00:55 -07:00
Lidi Zheng 7502a2311a
Try cleaner separation
* reduce possible contamination of environment variables
2018-10-29 22:48:35 -07:00
Lidi Zheng 688db0ec5b
Remove the environment variable changing line
* This commit failed `tools/run_tests/artifacts/build_artifact_csharp.sh`
* It doesn't make any sense!
2018-10-29 21:14:49 -07:00
Lidi Zheng 9569ebe770 Add reference to the issue 2018-10-29 16:38:20 -07:00
Lidi Zheng 465886533f Ensure libboringssl.a is always built for Python 2018-10-29 16:35:21 -07:00
Stuart Bishop 11ab724b97
Handle missing globals in Python Channel destructors
If the last reference to a Python object is at module scope, when
its destructor is run before program termination it may find that
the globals it requires no longer exist. Destructors of objects
likely to be stored at module global scope need to check that
globals exist before attempting to use them, to avoid warnings
being printed by the Python interpreter.

See grpc#17004
2018-10-26 00:54:21 +07:00
Mark D. Roth 496d0676c8
Merge pull request #16507 from markdroth/health_checking_client
Health checking client
2018-10-24 13:17:01 -07:00
Mark D. Roth f85fd026e3 Client-side health checking support. 2018-10-24 12:29:04 -07:00