16 Commits

Author SHA1 Message Date
Alex Miller
e8f994965d python: Post-API Version 620, @fdb.transactional on a generator will throw.
Previously, writing code like

    @fdb.transactional
    def foo(tr):
      yield tr.get('a')
      yield tr.get('b')

    print(foo(db))

was accepted by the python bindings, but had surprising semantics.  The
function returned by @fdb.transactional opens a transaction, runs foo(),
commits the transaction, and then returns the generator returned by foo().
This generator then uses the committed transaction.  This worked before API
version 410 (FDB 4.1), and hasn't worked since.  This will also be a problem if
a closure is returned from foo() that contains `tr`, but it's much harder to
check that in Python.

Rather than allow users to hit an unexpected and mysterious "Operation issued
while a commit was outstanding" exception, it's nicer to explicitly highlight
this problem as soon as we can.  Unfortunately, we have no way to know that a
function will return a generator until we call it, so that's the soonest we can
give a more informative error.
2019-06-19 01:38:35 -07:00
Chris Donati
f1331dbac6 Improve Python KeySelector representation
Python 2 resolves escape characters when printing byte strings,
which doesn't seem useful in this context.

I replaced __str__ since it defaults to __repr__ and the change
should be suitable for both cases.
2019-03-31 11:54:36 -07:00
A.J. Beamon
32b3c2ad69 Add comment for the code where we replace the semaphore in the exception handler 2019-02-11 10:35:29 -08:00
A.J. Beamon
5bf7e72fc5 If the semaphore acquire is interrupted (e.g. by a signal), then replace it with a new one so that subsequent futures will still work. 2019-02-11 10:22:19 -08:00
A.J. Beamon
8960670694 Python now blocks on a future in Python rather than in native code to preserve Python's signal handling functionality. In particular, this means that ctrl-c will work in the REPL. 2019-02-08 13:51:01 -08:00
A.J. Beamon
ec995ebef0 _CBFUNC should be defined outside init_c_api, both because it doesn't depend on the C API and because it is used elsewhere and wasn't available globally as previously written 2019-01-25 11:32:49 -08:00
A.J. Beamon
401f8a6774 Python and Ruby bindings displayed an unhelpful error if trying to load an old incompatible fdb_c with a new binding. 2019-01-14 10:41:54 -08:00
A.J. Beamon
bfa97d7ff2 Address review comments 2019-01-10 12:28:14 -08:00
A.J. Beamon
890a0f3e82 Merge branch 'master' into remove-cluster-from-bindings
# Conflicts:
#	bindings/flow/fdb_flow.actor.cpp
2018-11-26 12:01:03 -08:00
A.J. Beamon
a2630a68a6 We can't use async as a variable name in python 3.7 because it's now a keyword. Support gevent's new 'async_' name. 2018-10-09 09:51:04 -07:00
A.J. Beamon
d5357d2439 Update all of the bindings to use the new C API and deprecate or remove unneeded parts of their APIs. 2018-10-02 15:28:46 -07:00
Jay Kominek
fb33412b3a use inspect.getfullargspec when available
getargspec was deprecated in python3, this should use
getfullargspec when available, and degrade gracefully
otherwise.
2018-06-08 01:07:18 -06:00
Alec Grieser
0bae9880f1 remove trailing whitespace from our copyright headers ; fixed formatting of python setup.py 2018-02-21 10:25:11 -08:00
Alec Grieser
e104c21160 tweaks to fix some places where python format rewrite looked kind of bad 2018-02-07 16:59:59 -08:00
Alec Grieser
57986cfe00 format python files to be roughtly pep8 compliant 2018-01-24 19:06:58 -08:00
FDB Dev Team
a674cb4ef4 Initial repository commit 2017-05-25 13:48:44 -07:00