Add args/kwargs support to ClientSession.with_transaction()

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: API
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In PYTHON-1671, we discussed whether to support passing arbitrary arguments to the callback like this:

      def callback(session, custom_arg, custom_kwarg=None):
          # Transaction operations...
      
      with client.start_session() as session:
          ret = session.with_transaction(
              callback, args=('custom_arg',), kwargs=dict(custom_kwarg=10))
      

      This args/kwargs API matches the standard library's API for threading.Thread and multiprocessing.Process.

      However, we opted to not add support for this because there is an easy alternative; using a lambda like this:

      with client.start_session() as session:
          ret = session.with_transaction(
              lambda s: callback(s, 'custom_arg', custom_kwarg=10))
      

      We also wanted to get feedback from real users before adding more options to the API.

              Assignee:
              Unassigned
              Reporter:
              Shane Harvey
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: