Details
-
Improvement
-
Resolution: Fixed
-
Major - P3
-
None
-
None
-
None
Description
One of Motor's messiest problems is how to support Futures alongside its original callback-based API:
# Old-fashioned:
|
def callback(result, error):
|
if error:
|
print(error)
|
else:
|
print(result)
|
|
def func():
|
motor_client.db.collection.insert_one({'_id': 1}, callback=callback)
|
|
# Modern:
|
@gen.coroutine
|
def func():
|
result = yield motor_client.db.collection.insert_one({'_id': 1})
|
|
# Contemporary:
|
async def func():
|
result = await motor_client.db.collection.insert_one({'_id': 1})
|
After a discussion with Tornado's maintainer I've decided that Motor 2.0 should drop the old-fashioned callback interface.
Attachments
Issue Links
- is related to
-
MOTOR-251 Deprecate callback interface
-
- Closed
-