Uploaded image for project: 'Motor'
  1. Motor
  2. MOTOR-250

Delete callback interface

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 2.0
    • 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

        Activity

          People

            jesse@mongodb.com A. Jesse Jiryu Davis
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: