Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1915

Prohibit copying ClientSession objects

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.0
    • None
    • Minor Change

    Description

      It should not be possible to copy a ClientSession. A ClientSession maintains transaction state which cannot be duplicated. Also when a ClientSession is copied, the underlying server session is also duplicated, eventually resulting in duplicate _ServerSession objects in the pool:

      >>> import copy
      >>> s = client.start_session()
      >>> s._server_session
      <pymongo.client_session._ServerSession object at 0x10408b438>
      >>> s2 = copy.copy(s)
      >>> s._server_session
      <pymongo.client_session._ServerSession object at 0x10408b438>
      >>> s2._server_session
      <pymongo.client_session._ServerSession object at 0x10408b438>
      >>> client._topology._session_pool
      deque([])
      >>> s.end_session()
      >>> s2.end_session()
      >>> client._topology._session_pool
      deque([<pymongo.client_session._ServerSession object at 0x10408b438>, <pymongo.client_session._ServerSession object at 0x10408b438>])
      

      Attachments

        Activity

          People

            julius.park@mongodb.com Julius Park
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: