Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I am very much new to coding python script, i wrote a code in python where the functions can scan a list of remote target but the threads dies quick, The problem is that the thread dies and code ends before the scan is entirely complete.

What I have tried:

for i in range(400):
	try:
		thread=consumer(quee)
		thread.setDaemon(True)
		thread.start()
	except:
		print "Working only with %s threads"%i
		break
Posted
Updated 20-Jul-21 9:52am
v7

You need to ensure that the main thread of your program does not terminate while child threads are active. See threading — Thread-based parallelism — Python 3.9.6 documentation[^].

[edit]
Note also that trying to run 400 threads together will slow your system down dramatically. Running more than 3 or 4 together wil not get your work done faster.
[/edit]
 
Share this answer
 
v2
Comments
CPallini 21-Jul-21 1:50am    
5.
for i in range(400):
	try:
		thread=consumer(quee)
		thread.setDaemon(True)
		thread.start()
               thread.excepthook()
	except:
		print "Working only with %s threads"%i
		break
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900