Commit Graph

405 Commits

Author SHA1 Message Date
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
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
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
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 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 8a0b08b574 Migrate tests from Python 3.4 to Python 3.7 2018-11-06 15:37:51 -08: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
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
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
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
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
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
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 247b5b70c4 Merge branch 'master' of https://github.com/grpc/grpc into channelz 2018-10-15 15:59:36 -04:00
ncteisen c27d2fcbbe Ban gevent test 2018-10-15 15:59:27 -04:00
Lidi Zheng 08588f7077
Merge pull request #16864 from lidizheng/master
Fix Exception throw for invalid channel args
2018-10-15 09:58:08 -07:00
Lidi Zheng 118e134ded fix Exception throw for invalid channel args
* unit test included
* throw ValueError exception from Cython to Python
* prevent the deconstruction method from failing when Channel initialization failed
2018-10-14 23:33:58 -07:00
Mehrdad Afshari 9d2f985f55 Revert "Bazel rules for gRPC Python interop tests"
This reverts commit 9172775bc8.
2018-10-12 12:12:36 -07:00
Mehrdad Afshari 45e8ada064 Revert "Bazel rules for Python grpcio_reflection"
This reverts commit 2e78e516ad.
2018-10-12 12:12:29 -07:00
Nathaniel Manista 73419c49ac
Merge pull request #16831 from ghostwriternr/bazel-python-reflection
Bazel rules for Python grpcio_reflection.
2018-10-12 13:27:26 +02:00
Nathaniel Manista 8ae3285323
Merge pull request #16813 from ghostwriternr/bazel-python-interop-tests
Bazel rules for gRPC Python interop tests.
2018-10-12 10:14:13 +02:00
Naresh 2e78e516ad
Bazel rules for Python grpcio_reflection 2018-10-11 09:14:58 +00:00
Naresh 9172775bc8 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-10-11 08:43:34 +00:00
Naresh 873e0757cb
Bazel rules for Python grpcio_health_checking
Add Bazel rules for building and testing grpcio_health_checking.

An unofficial fork for rules_protobuf is used for now as it incorporates
a change (#196 by duduko on the upstream repo pubref/rules_protobuf)
which allows the protoc compiler to compile generated protos too. This
was not merged because the change was failing for golang, but works as
expected for Python.

This is needed because grpcio_health_checking fetches it's proto file
from a different directory (previously achived through setup.py) and
thus needs to be moved to the required location within bazel-genfiles
using a genrule.
2018-10-09 17:04:11 +00:00
Stanley Cheung e5ce1e36e6 Regenerate projects 2018-10-08 15:50:50 -07:00
Nathaniel Manista 83b678220e
Merge pull request #16335 from ghostwriternr/python_bazel_4
Add Bazel targets for (some) Python unit tests.
2018-10-08 14:44:20 +02:00
Naresh e80230ae6f
Add Bazel targets for Python unit tests
There are exactly 50 tests under grpcio_tests/tests/testing and
grpcio_tests/tests/unit for gRPC Python. Add Bazel targets for 44 of
them. unit._reconnect_test has been left out for now due to an
unexpected RuntimeError (#16336) and unit._server_ssl_cert_config_test
because of changes needed to the import path within
src/python/grpcio_tests/tests/testing/proto/services.proto (will
possibly be included as a fix to #15370).

The count of tests here is reported the way unittest counts tests, which
is the number of individual unit test classes it sees. This will be
different from Bazel's count, which counts the number of Bazel test
targets, which (by convention mostly) is one per test module.
2018-10-03 11:11:27 +00:00
Nathaniel Manista 9eebb6d13d
Merge pull request #16378 from ghostwriternr/module-level-logger-fix
Configure module level loggers with basicConfig().
2018-09-06 17:45:50 +02:00
Juanli Shen 8ceb27a324 Regenerate projects 2018-08-27 14:27:55 -07:00
Juanli Shen 142acb3b0f
Merge pull request #16425 from lamby/spelling-errors
Fix a number of spelling errors.
2018-08-22 14:20:24 -07:00
Eric Gribkoff f8cf7ee56d Support gRPC Python client-side fork with epoll1
A process may fork after invoking grpc_init() and use gRPC in the child
if and only if the child process first destroys all gRPC resources
inherited from the parent process and invokes grpc_shutdown().
Subsequent to this, the child will be able to re-initialize and use
gRPC. After fork, the parent process will be able to continue to use
existing gRPC resources such as channels and calls without interference
from the child process.

To facilitate gRPC Python applications meeting the above constraints,
gRPC Python will automatically destroy and shutdown all gRPC Core
resources in the child's post-fork handler, including cancelling
in-flight calls (see detailed design below). From the client's
perspective, the child process is now free to create new channels and
use gRPC.
2018-08-22 10:34:54 -07:00
Chris Lamb fba18d8551 Fix a number of spelling errors. 2018-08-22 16:52:46 +01:00
Mehrdad Afshari 0aa1bd2ed4 Ensure thread_pool is not None for grpc.Server 2018-08-21 17:29:35 -07:00
Naresh a20e2073c1
Configure module level loggers with basicConfig()
Module level loggers were introduced to gRPC Python in 06e1683, but
missed configuring these, leading to 'No handler found for module'
errors. Using the root logger implicitly calls basicConfig() which does
the basic configuration for the logging system by creating a
StreamHandler with a default Formatter and adding it to the logger. But
this is not the case for module level loggers.

Fix this issue by explicitly calling logging.basicConfig().
2018-08-17 12:24:58 +00:00
Jan Tattermusch 02d4afb94c yapf code 2018-08-07 14:28:41 +02:00
Jan Tattermusch bc8495da7a upgrade python to protobuf 3.6.0 2018-08-07 14:28:40 +02:00
Naresh 848fd9d75f
Minimal Bazel BUILD files for grpcio Python
Follow-up on the additions in #15992. Pad the grpcio Python package
with necessary BUILD files along with 2 simple tests.
2018-08-02 14:46:36 +00:00
Mehrdad Afshari b12f0aaf07 Add SERVICE_NAME to reflection/health 2018-07-26 11:45:59 -07:00
Mehrdad Afshari b928f99fdf Disable ChannelConnectivityTest for the Beta API
The Beta API has been unsupported for a while and
we plan to disable the flaky tests in the Beta API
as we see them before we entirely remove it.
2018-07-25 10:47:17 -07:00
Srini Polavarapu 8c9af7464c Regenerate projects 2018-07-19 09:52:56 -07:00
Srini Polavarapu d6616280d3
Merge pull request #15694 from srini100/bump-to-v1.14
Bump master to v1.14
2018-06-14 19:57:13 -07:00
kpayson64 30a0187aaa
Merge pull request #15744 from kpayson64/disable_lru
Disable LRU cache test on gevent
2018-06-13 15:18:14 -07:00
kpayson64 521246e2c5 Disable LRU cache test on gevent 2018-06-13 14:03:09 -07:00
Nathaniel Manista b436d56d8b
Merge pull request #15689 from nathanielmanistaatgoogle/generic-rpc-handler-validation
Check conformance to grpc.GenericRpcHandler type.
2018-06-11 16:00:48 -07:00
Srini Polavarapu c79c156307 Regenrate projects 2018-06-08 17:01:18 -07:00
Mehrdad Afshari 92a06353e2
Merge pull request #15682 from mehrdada/bump-pylint
Bump pylint to 1.9.2
2018-06-08 15:21:29 -07:00
Nathaniel Manista 369d827445 Check conformance to grpc.GenericRpcHandler type 2018-06-08 21:07:14 +00:00
Nathaniel Manista 8872a312c3
Merge pull request #14879 from santoshankr/python_ssl_session_cache_lru
TLS session resumption support for Python clients.
2018-06-08 11:31:33 -07:00
Mehrdad Afshari 6eac8c5e88 Run yapf to reformat Python code 2018-06-07 23:56:41 -07:00
Mehrdad Afshari de1718c1c0 Remove unused _junkdrawer 2018-06-07 23:38:50 -07:00
Mehrdad Afshari bfbd192a82 Fix raising-format-tuple pylint warning 2018-06-07 23:32:46 -07:00
Mehrdad Afshari b6955d996f Refactor to avord redefining argument 2018-06-07 23:30:34 -07:00
Mehrdad Afshari c095c5c847 Fix arguments-differ pylint warning 2018-06-07 23:26:38 -07:00
Mehrdad Afshari 6c44fd6e25 Fix useless-super-delegation pylint warnings 2018-06-07 23:22:19 -07:00
Nathaniel Manista 06e1683c7c
Merge pull request #14557 from ghostwriternr/py-custom-logger
Update logging in Python to use module-level logger.
2018-06-07 19:31:46 -07:00
Santosh Ananthakrishnan fd4c5dd031 TLS session resumption support for Python clients
This change adds an experimental ssl_session_cache_lru function to the
Python API that returns an encapsulated grpc_ssl_session_cache (#14483).
Python clients may use this object as an argument for the
grpc.ssl_session_cache channel option if they wish to cache and resume
TLS sessions with a server.
2018-06-07 22:20:31 +00:00
Naresh 2e113ca6b2 Update logging in Python to use module-level logger
All logging in Python so far was done with the root logger, resulting
in logs like: `ERROR:Exception calling application:`. With module-level
loggers, the logs will instead include the module in which the
exception is raised: `ERROR:grpc._server:Exception calling application:`
2018-05-31 08:08:25 +00:00
kpayson64 deebcfea01 Use the correct proto for benchmark_serivce 2018-05-29 14:21:21 -07:00
Noah Eisen 0b8b9a08e2 Surfaces debug_error_string to Python API
In case of error, the user can access call.debug_error_string()
which contains a string representation of error from the c core.
2018-05-17 07:42:02 -07:00
Mehrdad Afshari ac6aaa3f0b Install futures package only on Python 2 2018-05-14 17:02:03 -07:00
kpayson64 6d6c780ffc Merge remote-tracking branch 'upstream/master' into remove_cleanup_thread 2018-05-03 15:50:56 -07:00
Mehrdad Afshari 2d43a45ad1 Regenerate projects 2018-05-02 22:49:52 -07:00
Nathaniel Manista bccd32dafa Add grpc.Channel.close 2018-05-02 23:59:15 +00:00
Nathaniel Manista ca7ba4d0ac Keep Core memory inside cygrpc.Channel objects
This removes invocation-side completion queues from the _cygrpc API.
Invocation-side calls are changed to no longer share the same lifetime
as Core calls.

Illegal metadata is now detected on invocation rather than at the start
of a batch (so passing illegal metadata to a response-streaming method
will now raise an exception immediately rather than later on when
attempting to read the first response message).

It is no longer possible to create a call without immediately starting
at least one batch of operations on it. Only tests are affected by this
change; there are no real use cases in which one wants to start a call
but wait a little while before learning that the server has rejected
it.

It is now required that code above cygrpc.Channel spend threads on
next_event whenever events are pending. A cygrpc.Channel.close method
is introduced, but it merely blocks until the cygrpc.Channel's
completion queues are drained; it does not itself drain them.

Noteworthy here is that we drop the cygrpc.Channel.__dealloc__ method.
It is not the same as __del__ (which is not something that can be added
to cygrpc.Channel) and there is no guarantee that __dealloc__ will be
called at all or that it will be called while the cygrpc.Channel
instance's Python attributes are intact (in testing, I saw both in
different environments). This commit does not knowingly break any
garbage-collection-based memory management working (or "happening to
appear to work in some circumstances"), though if it does, the proper
remedy is to call grpc.Channel.close... which is the objective towards
which this commit builds.
2018-05-02 18:24:47 +00:00
kpayson64 a0bc0ac169 Remove CleanupThread
This is no longer needed with the addition of a close() API that allows
clean shutdown.
2018-04-30 14:03:47 -07:00
Mehrdad Afshari b3069b095d
Merge pull request #15113 from mehrdada/pylint-tests-1
Eliminate some of the more esoteric pylint suppressions for tests
2018-04-19 11:23:49 -07:00
Mehrdad Afshari 1d74fa6748
Merge pull request #15114 from mehrdada/bump-protobuf-submodule-to-3.5.2
Bump protobuf submodule to 3.5.2
2018-04-19 10:50:44 -07:00
Mehrdad Afshari dd9697fef8 Eliminate broad-except suppression 2018-04-19 10:39:39 -07:00
Mehrdad Afshari 1611946161 Eliminate bare-except suppression 2018-04-19 10:39:38 -07:00
Mehrdad Afshari 4cc8ea9be1 Eliminate old-style-class suppression 2018-04-19 10:39:38 -07:00
Mehrdad Afshari fc3bb7c1f9 Eliminate wildcard-import suppression 2018-04-19 10:39:38 -07:00
Mehrdad Afshari 86d04c2e34 Eliminate function-redefined suppression 2018-04-19 10:39:38 -07:00
Mehrdad Afshari bc947ada75 Eliminate unnecessary-lambda suppression 2018-04-19 10:39:38 -07:00
Mehrdad Afshari 4c87620da2 Eliminate undefined-variable suppression 2018-04-19 10:39:38 -07:00
Mehrdad Afshari a6bf3ccac8 Eliminate non-iterator-returned suppression 2018-04-19 10:39:38 -07:00
Mehrdad Afshari a7926f9a4c Eliminate undefined-loop-variable suppression 2018-04-19 10:39:38 -07:00
Mehrdad Afshari 327b3fb6f8 Eliminate raising-bad-type suppression 2018-04-19 10:39:38 -07:00