threading + variables

Martin von Loewis loewis at informatik.hu-berlin.de
Tue Sep 18 13:24:21 EDT 2001


"Adonis Vargas" <deltapigz at telocity.com> writes:

> im writting a simple script in which uses some enviroment variables
> (enviroment variables im mentioning are variables declared outside of
> functions) therefore i load a function into a thread and find the function
> is having a hard time trying to find the variable; and errors as if it were
> and unreferenced variable.

What error is this specifically? If you have a module-global variable,
it will be accessible from any thread. If you want to access the
variable from multiple threads, you need to protect it with a lock;
see thread.allocate_lock. However, the variable will still be there...

> def updt_auth_list(addr):
>     if len(AUTH_LIST) >= 100:
>         ulist = AUTH_LIST.pop(0)
>         del ulist

That statement is without any effect: it deletes the local variable
ulist, which is then not further used in this function.

Regards,
Martin



More information about the Python-list mailing list