Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOTOR-86 Can't return values from internal coros.
Consequences of PEP 479. Motor not only supports users' coroutines, it uses coroutines to implement of some of its own features, like client.open() and gridfs.put(). Some of those coroutines return values. In Tornado and Python 2.6, Motor's internal coros could return values with "raise gen.Return(value)", and in Python 2.7 could alternatively use "raise StopIteration(value)". The latter also works in Python 3.3+ and asyncio, so this worked everywhere: @motor_coroutine def f(): raise framework.return_value(value) ... where framework.return_value is gen.Return or StopIteration. In Python 3.5 with asyncio, however, raising StopIteration to return from a coroutine is prohibited (PEP 492 says, "PEP 479 is enabled by default for coroutines"). Only "return value" works. It's possible there's a workaround for now, but it will break in Python 3.7 (PEP 479 transition plan: "Python 3.7: Enable new semantics everywhere"). For the future's sake, stop returning values from Motor's internal coroutes and use callbacks and explicit Futures to implement returns. Still TODO: reimplement parallel_collection_scan.
- Loading branch information
Showing
7 changed files
with
222 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.