PYTHON-1915 Prohibit copying ClientSession objects (#726)
This commit is contained in:
parent
0fa86c8ee1
commit
4e086ba218
@ -89,4 +89,5 @@ The following is a list of people who have contributed to
|
||||
- Paul Fisher (thetorpedodog)
|
||||
- Julius Park (juliusgeo)
|
||||
- Khanh Nguyen (KN99HN)
|
||||
- Henri Froese (henrifroese)
|
||||
- Henri Froese (henrifroese)
|
||||
- Ishmum Jawad Khan (ishmum123)
|
||||
|
||||
@ -953,6 +953,9 @@ class ClientSession(object):
|
||||
if self._snapshot_time is not None:
|
||||
rc['atClusterTime'] = self._snapshot_time
|
||||
|
||||
def __copy__(self):
|
||||
raise TypeError('A ClientSession cannot be copied, create a new session instead')
|
||||
|
||||
|
||||
class _ServerSession(object):
|
||||
def __init__(self, generation):
|
||||
|
||||
@ -716,6 +716,10 @@ class TestSession(IntegrationTest):
|
||||
snapshot=True):
|
||||
pass
|
||||
|
||||
def test_session_not_copyable(self):
|
||||
client = self.client
|
||||
with client.start_session() as s:
|
||||
self.assertRaises(TypeError, lambda: copy.copy(s))
|
||||
|
||||
class TestCausalConsistency(unittest.TestCase):
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user