in Education by
I have this script: import threading, socket for x in range(800) send().start() class send(threading.Thread): def run(self): while True: try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("www.google.it", 80)) s.send ("test") print ("Request sent!") except: pass And at the place of "Request sent!" I would like to print something like: "Request sent! %s" % (the current number of the thread sending the request) What's the fastest way to do it? --SOLVED-- import threading, socket for x in range(800) send(x+1).start() class send(threading.Thread): def __init__(self, counter): threading.Thread.__init__(self) self.counter = counter def run(self): while True: try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("www.google.it", 80)) s.send ("test") print ("Request sent! @", self.counter) except: pass JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

Related questions

0 votes
    What will be the output of the following Python code? >>>list1 = [1, 3] >>>list2 = list1 >>>list1[0] = 4 >>>print(list2) a) [1, 4] b) [1, 3, 4] c) [4, 3] d) [1, 3]...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code snippet? for i in [1, 2, 3, 4][::-1]: print (i) a) 4 3 2 1 b) error c) 1 2 3 4 d) none of the mentioned...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    write a program in Python to print the sum of the following series: s=1+x+x^2+x^3+…..+x^n Select the correct answer from above options...
asked Dec 9, 2021 in Education by JackTerrance
0 votes
    write a program in python to obtain 3 numbers and print their sum. Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    can anyone please help me out for this question Write a program to create two threads, so one thread will print ... between 11 to 20. Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    can anyone please help me out for this question Write a program to create two threads, so one thread will print ... between 11 to 20. Select the correct answer from above options...
asked Dec 18, 2021 in Education by JackTerrance
0 votes
    I am using Eclipse with Pydev and googleAppengine. I have python 2.7 installed. I am trying to run ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    In the next examlpe I have Socket server handled in the thread. In the handle function we create Thread ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    In the next examlpe I have Socket server handled in the thread. In the handle function we create Thread ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    In the next examlpe I have Socket server handled in the thread. In the handle function we create Thread ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    What will be the output of the following Python code? print('*', "abcde".center(6), '*', sep='') a) * abcde * b) *abcde * c) * abcde* d) * abcde *...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? print("abc. DEF".capitalize()) a) Abc. def b) abc. def c) Abc. Def d) ABC. DEF...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc ... (id(q) == foo(q)) a) Error b) None c) False d) True...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? class tester: def __init__(self, id): self.id = str(id) id="224" >>>temp ... >>>print(temp.id) a) 12 b) 224 c) None d) Error...
asked Jan 2, 2023 in Technology by JackTerrance
...