File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 4949 get_callbacks ,
5050 is_s3express_bucket ,
5151)
52+ import os
5253
5354logger = logging .getLogger (__name__ )
5455
@@ -67,6 +68,20 @@ def acquire_crt_s3_process_lock(name):
6768 # lock is set as a global so that it is not unintentionally garbage
6869 # collected/released if reference of the lock is lost.
6970 global CRT_S3_PROCESS_LOCK
71+
72+ def after_in_child ():
73+ global CRT_S3_PROCESS_LOCK
74+ if CRT_S3_PROCESS_LOCK is not None :
75+ # the lock is not belong to the forked child process.
76+ # Release the lock after fork in child process.
77+ CRT_S3_PROCESS_LOCK .release ()
78+ CRT_S3_PROCESS_LOCK = None
79+
80+ # Check if we've already registered using a function attribute
81+ if not getattr (acquire_crt_s3_process_lock , '_fork_handler_registered' , False ):
82+ os .register_at_fork (after_in_child = after_in_child )
83+ acquire_crt_s3_process_lock ._fork_handler_registered = True
84+
7085 if CRT_S3_PROCESS_LOCK is None :
7186 crt_lock = awscrt .s3 .CrossProcessLock (name )
7287 try :
You can’t perform that action at this time.
0 commit comments