Does the per-thread getting of a value, running the sub-function, and marking a completion. None of the global variables are assigned locally in order to ensure a global reference.
(logger, tnum, q, port, command, zones_struct, zgrab_collection)
| 729 | |
| 730 | |
| 731 | def process_data(logger, tnum, q, port, command, zones_struct, zgrab_collection): |
| 732 | """ |
| 733 | Does the per-thread getting of a value, running the sub-function, and marking a completion. |
| 734 | None of the global variables are assigned locally in order to ensure a global reference. |
| 735 | """ |
| 736 | |
| 737 | while not global_exit_flag: |
| 738 | global_queue_lock.acquire() |
| 739 | if not global_work_queue.empty(): |
| 740 | data = [] |
| 741 | i = 0 |
| 742 | while i < global_queue_size: |
| 743 | data.append(q.get()) |
| 744 | i = i + 1 |
| 745 | if global_work_queue.empty(): |
| 746 | break |
| 747 | global_queue_lock.release() |
| 748 | logger.debug("Thread %s processing %s" % (str(tnum), data)) |
| 749 | try: |
| 750 | process_thread( |
| 751 | logger, data, port, command, zones_struct, zgrab_collection, tnum |
| 752 | ) |
| 753 | except Exception as ex: |
| 754 | logger.warning("Thread error processing: " + str(data)) |
| 755 | logger.warning(str(ex)) |
| 756 | for _ in range(0, i): |
| 757 | q.task_done() |
| 758 | else: |
| 759 | global_queue_lock.release() |
| 760 | time.sleep(1) |
| 761 | |
| 762 | |
| 763 | class ZgrabThread(threading.Thread): |