Import in a separate thread

cyberco cyberco at gmail.com
Sat Feb 25 07:08:06 EST 2006


I want to import a long list of modules in a separate thread to speed
things up. How can I make the modules imported in that separate thread
accessible outside the method?

===========================
import os

# import rest in a separate thread
def importRest():
    import audio
    import socket
thread.start_new_thread(importRest,())

# audio.somemethod()  would fail here
===========================




More information about the Python-list mailing list