threading + variables

Adonis Vargas deltapigz at telocity.com
Tue Sep 18 01:12:38 EDT 2001


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. now i *understand* why this is occuring, but
would like to know any other efficient ways in doing this; here is a
supplied code and the work around i was able to create:

*bottom line i want to call/modify a variable outside of a thread in the
most efficient way*

(outside of thread)
AUTH_LIST = []

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

(in-threaded function)
if data == 'NFP/0.1 CONNECT':
    c.send('NFP/0.1 OK\n')
    updt_auth_list(a[0])
    print '%s->AUTH OK (%s)'%(a[0], data)

any help would be greatly appciated.

Adonis

OJO: thanks for all who have posted replies to my numerous amounts of
questions and sorry for having to post too many questions and not referring
to the help files on python.org; just i prefer to see other methods aside
from those presented on the help site.







More information about the Python-list mailing list