If you are looking to run a child process in the background while returning quickly without killing the child process in Python, os.fork() works very well. I'm using this strategy to list all the s3 objects of a bucket to return only the last one, which takes 8min30s. Of course we don't want a synchronous call here.

#python #os #fork #s3

Follow

@jriou given that your just waiting on the response of network traffic, an async IO approach would likely be better than sub processes. Depending on library support, etc.

@intrbiz Sure. If your main program can afford to wait for the child process or thread to finish, don't use os.fork.

Sign in to participate in the conversation
Mastodon

Time for a cuppa... Earl Grey please!