Click here to Skip to main content
15,894,291 members

Comments by Dasisqo (Top 14 by date)

Dasisqo 21-Jul-21 8:24am View    
I have understood from explanations here than python does work with one thread at a time, what i am trying is to make the thread to be multiple and execute each line of thread simultaneously. Printing out more threads of the function and execute each line at a time.

From my code edition which is
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

The function prints out one line and execute it. I am asking if there are other means to make the work multi threading and execute each line at a time.
Dasisqo 21-Jul-21 7:34am View    
If i run the code with the tread

for i in range(400):
try:
thread=consumer(quee)
thread.setDaemon(True)
thread.start()
except:
print "Working only with %s threads"%i
break

The thread will run fine for a second and will die without the functions not complete in the code.
I decided to set the thread with thread.excepthook()

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

The code will work fine with (0) threads but it is slower.
Dasisqo 17-Jul-21 17:02pm View    
Deleted
I will wait for the coder to reach my request, thanks in advance
Dasisqo 16-Jul-21 18:44pm View    
Deleted
def run(self):
global to_checks
while self.work:
if not self.connected:
if self.attemp<=0:
return 0
self.connect()
self.attemp-=1
if len(to_check)>0:
self.find()
time.sleep(self.interval)
Dasisqo 16-Jul-21 18:44pm View    
Deleted
def run(self):
global to_checks
while self.work:
if not self.connected:
if self.attemp<=0:
return 0
self.connect()
self.attemp-=1
if len(to_check)>0:
self.find()
time.sleep(self.interval)