Search code examples
pythonmultithreadingmultiprocessingbackground-process

python zip extraction in background


I am uploading large zip files in to the system. where zip extraction may take several minutes. I want to send this zip extraction in to the background as don't want to block the UI.

_.unzip(filePath ,uploadPath) #is it possible to make it async or independent?

Solution

  • Use the threading module!

    import threading
    
    def do_unzipping():
        _.unzip(filePath ,uploadPath)
    
        update_ui("Unzipping Finished!")
    
    threading.Thread(target = do_unzipping).start()
    continue_with_unblocked_ui()
    

    Nice threading tutorial.