r/learnpython • • 14h ago

i got UnboundLocalError: local variable 'queue' referenced before assignment, how to fix please

def main(ips, users, passwords, ThreadNumber):

queue = queue.Queue(maxsize=20000)

for t in range(ThreadNumber):

try:

t = Apophis(queue)

t.daemon = True

t.start()

except Exception as e:

break

0 Upvotes

3 comments sorted by

1

u/supercoach 8h ago

I assume you're importing queue, so if you are, you need to consider it a reserved word and not use it for a variable name. Change the name of the var to anything else and you should be fine.

1

u/First-Ad6991 2h ago

it worked, thanks.