Commit Graph

4032 Commits

Author SHA1 Message Date
Nathaniel Manista 97993b65b3 Fix a thread leak bug.
Successful operations were leaking the thread used for expiration
monitoring. This change ensures that the ExpirationManager for the
operation always has its abort() method called when the
TerminationManager for the operation judges the operation to have
terminated.
2015-02-20 18:14:00 +00:00
Thomas Wouters c04c573fb3 Clean up Python C API use in src/python/src/grpc/_adapter/*.c. Specifically:
- Use METH_O and METH_NOARGS where appropriate, modifying the C functions
   appropriately.  METH_O is for functions that take a single PyObject, and
   it's passed directly instead of 'args'.  METH_NOARGS is for functions
   that take no arguments, and they get called with just one argument
   ('self'.)

 - In PyArg_ParseTuple*() calls, specify the callable's name for more
   descriptive exception messages.

 - For tp_init functions (which always take keyword arguments) introduce
   keyword argument parsing (using the C local variables as keywords,
   although I don't know if they're the best names to use.) This is mostly
   as a way to show how keyword arguments are done in C.  An alternative
   method is to use _PyArg_NoKeywords(kwds) (see
   https://hg.python.org/cpython/file/70a55b2dee71/Python/getargs.c#l1820,
   but unfortunately it's not part of the official API,) or check manually
   that the dict is empty.

 - Check the return value of Python API functions that can return an error
   indicator (NULL or -1.) PyFloat_AsDouble is also one of these, but we
   don't check the return type (we would have to compare the result to 1.0
   with ==, which is not a thing you should do) so just call PyErr_Occurred
   unconditionally.

 - Change Py_BuildValue() calls with just "O" formats into PyTuple_Pack
   calls.  It requires less runtime checking.

 - Replace Py_BuildValue()/PyObject_CallObject pairs with
   PyObject_CallFunctionObjArgs (since all of them have just PyObject*
   arguments.) If the Py_BuildValue formats had included other types,
   PyObject_CallFunction() would have been easier, but no need in these
   cases.

 - Replace Py_BuildValue("f", ...) with PyFloat_FromDouble(...). Less
   runtime checking and parsing necessary, and more obvious in what it does.

 - In the PyType structs, replace "PyObject_HEAD_INIT(NULL) 0" with
   "PyVarObject_HEAD_INIT(NULL, 0)".  Anything with an ob_size struct member
   is a PyVarObject, although the distinction isn't all that import; it's
   just a more convenient macro.

 - Assign tp_new in the PyType structs directly, like all other struct
   members, rather than right before the PyType_Ready() call.

 - Remove PyErr_SetString() calls in places that already have a (meaningful)
   exception set.

 - Add a PyErr_Format() for an error return that wasn't setting an exception
   (PyObject_TypeCheck() doesn't set an exception.)

 - Remove NULL assignments to struct members in the error paths of the
   tp_init functions.  PyObject structs are always zeroed after allocation,
   guaranteed.  (If there's a way for them to already contain an object
   you'd use Py_CLEAR() to clear them, but that can't happen in these
   cases.)

 - Remove a few unnecessary parentheses.
2015-02-20 06:20:36 -08:00
Jayant Kolhe 6ef57ba3bf Merge pull request #589 from nathanielmanistaatgoogle/src-python-readme
Add a src/python/README.md.
2015-02-19 11:39:52 -08:00
Tim Emiola 222fbdf317 Merge pull request #608 from nathanielmanistaatgoogle/interfaces_test_case
Rename base/interfaces_test to base/interfaces_test_case.
2015-02-19 08:56:05 -08:00
Nathaniel Manista 3e2ebff833 Python early_adopter changes in anticipation of interop client. 2015-02-19 10:02:01 +00:00
Nathaniel Manista 1fbaad110f Rename base/interfaces_test to base/interfaces_test_case.
With this change the Python codebase now conforms to an
"if it ends with _test.py then it is an executable test"
rule.
2015-02-19 07:32:33 +00:00
Nathaniel Manista 9b98bd89af Add a src/python/README.md. 2015-02-18 22:47:25 +00:00
Craig Tiller ce5021b0b9 Add missing new-lines at end of file 2015-02-18 09:25:21 -08:00
Craig Tiller 190d360def Add missing new-lines at end of file 2015-02-18 09:23:38 -08:00
Craig Tiller 0605995e55 Update copyright to 2015 2015-02-18 08:34:56 -08:00
Craig Tiller 94640a3df9 Rework python, expand tool to make this easier 2015-02-17 20:42:05 -08:00
Craig Tiller 347b83c222 Merge github.com:grpc/grpc into copyright
Conflicts:
	src/python/src/__init__.py
	src/python/src/_adapter/__init__.py
	src/python/src/_framework/__init__.py
	src/python/src/_framework/base/__init__.py
	src/python/src/_framework/base/packets/__init__.py
	src/python/src/_framework/common/__init__.py
	src/python/src/_framework/face/__init__.py
	src/python/src/_framework/face/testing/__init__.py
	src/python/src/_framework/foundation/__init__.py
	src/python/src/_junkdrawer/__init__.py
2015-02-17 20:28:40 -08:00
Nathaniel Manista c25a3b35bd Python source reorganization.
A top-level "grpc" package is added and RPC Framework
is made public.
2015-02-18 02:46:17 +00:00
Craig Tiller c2c792113e Add copyrights to Python code 2015-02-16 12:00:01 -08:00
Nathaniel Manista 1d1f952731 The Python interoperability testing server. 2015-02-15 01:21:18 +00:00
Nathaniel Manista 2fe7cb7d6d Add an early adopter public API. 2015-02-15 01:19:21 +00:00
Nathaniel Manista 81337bb41f Add security to fore.ForeLink. 2015-02-15 01:18:41 +00:00
Nathaniel Manista a035afcfae Clean up setup.py and move it into src/. 2015-02-15 01:16:37 +00:00
Nathaniel Manista 6edb45189e Simplify _WrappedConsumer.moar. 2015-02-15 01:06:31 +00:00
Nathaniel Manista 83edf3e8d3 Change the interface of RPC Framework's Future interface.
Now our Future interface is as-API-compatible-as-possible with
Python's own concurrent.futures.Future.
2015-02-13 22:16:35 +00:00
Nathaniel Manista bc9773e105 Allow _low.Server objects to be passed a ServerCredentials. 2015-02-10 22:21:44 +00:00
Nathaniel Manista 49c877e579 Add a wrapping of grpc_server_credentials. 2015-02-10 22:17:55 +00:00
Craig Tiller c4f0ebe63b Prepare for the new batch call API.
Rename all core API functions that are on their way to deprecation with
an _old tag across all wrappings.
2015-02-02 15:39:31 -08:00
Nathaniel Manista 71723faa13 TODO fulfillment: use enum for enumerated types. 2015-02-02 17:26:01 +00:00
Nathaniel Manista a4ead5d91b Bring in the Python GRPC Adapter package. 2015-02-02 15:25:52 +00:00
Nathaniel Manista b8b0adfbf9 Refactoring of the Python build.
The source code is moved from src/python to
src/python/src. A setup.py is added at
src/python. The build_python.sh and
run_python.sh scripts are updated to build
and run the Python tests by building a
package and installing it in the developer's
Python 2.7 virtual environment.
2015-02-02 15:25:43 +00:00
Nathaniel Manista 7a3c38bed9 Add the _framework.face package. 2015-01-24 00:47:35 +00:00
Nathaniel Manista 21f29c6bf7 Add the _framework.base package. 2015-01-24 00:05:22 +00:00
Nathaniel Manista 61b5a81a1e Add the _framework.common package.
It's rather unimpressive at the moment with just
one module.
2015-01-23 21:42:39 +00:00
Nathaniel Manista b68f3d1746 Fill out the foundation package. 2015-01-23 21:32:47 +00:00
Nathaniel Manista fcd6c0c922 Correct an out-of-date path in a comment. 2015-01-23 20:54:58 +00:00
Nathaniel Manista 59d095a7df The logging_pool module. 2015-01-22 20:23:45 +00:00