MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / URLGetterThread

Class URLGetterThread

test/mod_wsgi_test/test_client.py:91–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89
90
91class URLGetterThread(threading.Thread):
92 # Class variables.
93 counter_lock = threading.Lock()
94 counter = 0
95
96 def __init__(self, options, urls, nrequests_per_thread):
97 super().__init__()
98 self.options = options
99 self.urls = urls
100 self.nrequests_per_thread = nrequests_per_thread
101 self.errors = 0
102
103 def run(self):
104 for _i in range(self.nrequests_per_thread):
105 try:
106 get(self.urls)
107 except Exception as e:
108 print(e)
109
110 if not self.options.continue_:
111 thread.interrupt_main()
112 thread.exit()
113
114 self.errors += 1
115
116 with URLGetterThread.counter_lock:
117 URLGetterThread.counter += 1
118 counter = URLGetterThread.counter
119
120 should_print = self.options.verbose and not counter % 1000
121
122 if should_print:
123 print(counter)
124
125
126def main(options, mode, urls):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68