mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	
		
			
	
	
		
			19 lines
		
	
	
	
		
			351 B
		
	
	
	
		
			Python
		
	
	
	
	
	
		
		
			
		
	
	
			19 lines
		
	
	
	
		
			351 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| 
								 | 
							
								import multiprocessing
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								multiprocessing.Lock()
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								def f():
							 | 
						||
| 
								 | 
							
								    print("ok")
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								if __name__ == "__main__":
							 | 
						||
| 
								 | 
							
								    ctx = multiprocessing.get_context("forkserver")
							 | 
						||
| 
								 | 
							
								    modname = "test.mp_preload"
							 | 
						||
| 
								 | 
							
								    # Make sure it's importable
							 | 
						||
| 
								 | 
							
								    __import__(modname)
							 | 
						||
| 
								 | 
							
								    ctx.set_forkserver_preload([modname])
							 | 
						||
| 
								 | 
							
								    proc = ctx.Process(target=f)
							 | 
						||
| 
								 | 
							
								    proc.start()
							 | 
						||
| 
								 | 
							
								    proc.join()
							 |