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

Delete callback interface

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.0
    • Affects Version/s: None
    • Component/s: None
    • None

      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.

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

              Created:
              Updated:
              Resolved: