File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,25 @@ def test_use_after_close(self):
329
329
with self .assertRaisesRegex (InvalidOperation , "Cannot use MongoClient after close" ):
330
330
client .admin .command ("ping" )
331
331
332
+ # Not available for versions of Python without "register_at_fork"
333
+ @unittest .skipIf (
334
+ not hasattr (os , "register_at_fork" ),
335
+ "register_at_fork not available in this version of Python" ,
336
+ )
337
+ def test_fork (self ):
338
+ opts = AutoEncryptionOpts (KMS_PROVIDERS , "keyvault.datakeys" )
339
+ client = rs_or_single_client (auto_encryption_opts = opts )
340
+
341
+ lock_pid = os .fork ()
342
+ if lock_pid == 0 :
343
+ client .admin .command ("ping" )
344
+ client .close ()
345
+ os ._exit (0 )
346
+ else :
347
+ self .assertEqual (0 , os .waitpid (lock_pid , 0 )[1 ])
348
+ client .admin .command ("ping" )
349
+ client .close ()
350
+
332
351
333
352
class TestEncryptedBulkWrite (BulkTestBase , EncryptionIntegrationTest ):
334
353
def test_upsert_uuid_standard_encrypt (self ):
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ def exit_cond():
53
53
if lock_pid == 0 :
54
54
os ._exit (exit_cond ())
55
55
else :
56
- self .assertEqual (0 , os .waitpid (lock_pid , 0 )[1 ] >> 8 )
56
+ self .assertEqual (0 , os .waitpid (lock_pid , 0 )[1 ])
57
57
58
58
def test_lock_object_id (self ):
59
59
"""
@@ -67,7 +67,7 @@ def test_lock_object_id(self):
67
67
if lock_pid == 0 :
68
68
os ._exit (int (ObjectId ._inc_lock .locked ()))
69
69
else :
70
- self .assertEqual (0 , os .waitpid (lock_pid , 0 )[1 ] >> 8 )
70
+ self .assertEqual (0 , os .waitpid (lock_pid , 0 )[1 ])
71
71
72
72
def test_topology_reset (self ):
73
73
"""
@@ -92,7 +92,7 @@ def test_topology_reset(self):
92
92
)
93
93
os ._exit (0 )
94
94
else : # Parent
95
- self .assertEqual (0 , os .waitpid (lock_pid , 0 )[1 ] >> 8 )
95
+ self .assertEqual (0 , os .waitpid (lock_pid , 0 )[1 ])
96
96
self .assertEqual (self .client ._topology ._pid , init_id )
97
97
child_id = parent_conn .recv ()
98
98
self .assertNotEqual (child_id , init_id )
You can’t perform that action at this time.
0 commit comments