Does the per-thread getting of value, running the sub-function, and marking a completion.
(logger, tnum, q, port, command, zone, zgrab_collection)
| 237 | |
| 238 | |
| 239 | def process_data(logger, tnum, q, port, command, zone, zgrab_collection): |
| 240 | """ |
| 241 | Does the per-thread getting of value, running the sub-function, and marking a completion. |
| 242 | """ |
| 243 | while not global_exit_flag: |
| 244 | global_queue_lock.acquire() |
| 245 | if not global_work_queue.empty(): |
| 246 | data = [] |
| 247 | i = 0 |
| 248 | while i < 5: |
| 249 | data.append(q.get()) |
| 250 | i = i + 1 |
| 251 | if global_work_queue.empty(): |
| 252 | break |
| 253 | global_queue_lock.release() |
| 254 | logger.debug("Thread %s processing %s" % (str(tnum), str(data))) |
| 255 | try: |
| 256 | process_thread( |
| 257 | logger, data, port, command, zone, zgrab_collection, tnum |
| 258 | ) |
| 259 | except Exception as ex: |
| 260 | logger.error("Thread error processing: " + str(data)) |
| 261 | logger.error(str(ex)) |
| 262 | for _ in range(0, i): |
| 263 | q.task_done() |
| 264 | else: |
| 265 | global_queue_lock.release() |
| 266 | time.sleep(1) |
| 267 | |
| 268 | |
| 269 | class ZgrabThread(threading.Thread): |