"cyberco" <[EMAIL PROTECTED]> writes:
> 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?

It won't speed things up unless the main thread is waiting for user
input during those imports, or something like that.  Threads in Python
don't really run in parallel.

> # import rest in a separate thread
> def importRest():
>     import audio
>     import socket
> thread.start_new_thread(importRest,())
> 
> # audio.somemethod()  would fail here

Here's one way:

def importRest():
   global audio
   import audio as local_audio
   audio = local_audio
   # etc. 

There's surely other ways that are better.  
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to