dbworkload 0.8.2__tar.gz → 0.8.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dbworkload
3
- Version: 0.8.2
3
+ Version: 0.8.3
4
4
  Summary: Workload framework
5
5
  License: GPLv3+
6
6
  Author: Fabio Ghirardello
@@ -36,6 +36,7 @@ FIFO = "dbworkload.pipe"
36
36
 
37
37
  logger = logging.getLogger("dbworkload")
38
38
 
39
+ force_exit = False
39
40
 
40
41
  HEADERS: list = [
41
42
  "elapsed",
@@ -95,7 +96,13 @@ def signal_handler(sig, frame):
95
96
  frame (_type_):
96
97
  """
97
98
  logger.info("KeyboardInterrupt signal detected. Stopping processes...")
99
+ global force_exit
100
+ if force_exit:
101
+ logger.warning("Forcibly quitting. You're rude!")
102
+ sys.exit(1)
98
103
 
104
+ force_exit = True
105
+
99
106
  # send the poison pill to each proc.
100
107
  # if dbworkload cannot graceful shutdown due
101
108
  # to processes being still in the init phase
@@ -104,13 +111,15 @@ def signal_handler(sig, frame):
104
111
  # and raise the queue.Full exception, forcing to quit.
105
112
  for q in queues.values():
106
113
  try:
107
- q.put("proc_end", timeout=0.1)
114
+ q.put("proc_end")
108
115
  except queue.Full:
109
116
  logger.error("Timed out")
110
117
  sys.exit(1)
111
118
 
112
119
  logger.debug("Sent poison pill to all procs")
113
- os.remove(FIFO)
120
+
121
+ if os.path.exists(FIFO):
122
+ os.remove(FIFO)
114
123
 
115
124
 
116
125
  def cycle(iterable, backwards=False):
@@ -181,18 +190,16 @@ def run(
181
190
  log_level: str,
182
191
  ):
183
192
  def gracefully_shutdown(by_keyinterrupt: bool = False):
184
- """
185
- wait for final stat reports to come in,
186
- then print final stats and quit
187
- """
193
+
194
+ logger.info("Gracefully shutting down...")
188
195
 
189
196
  end_time = int(time.time())
190
- _s = stats_received
197
+ # _s = stats_received
191
198
 
192
199
  if not by_keyinterrupt:
193
200
  for q in queues.values():
194
201
  try:
195
- q.put("proc_end", timeout=0.1)
202
+ q.put("proc_end")
196
203
  except queue.Full:
197
204
  logger.error("Timed out")
198
205
  sys.exit(1)
@@ -201,20 +208,23 @@ def run(
201
208
  if x.is_alive():
202
209
  x.join()
203
210
 
204
- while True:
205
- try:
206
- msg = to_main_q.get(block=True, timeout=2.0)
207
- if isinstance(msg, list):
208
- _s += 1
209
- stats.add_tds(msg)
210
- if _s >= active_connections:
211
- break
212
- else:
213
- logger.error("Timed out, quitting")
214
- sys.exit(1)
215
-
216
- except queue.Empty:
217
- break
211
+ # Commenting the below as in theory there shouldn't be any stats that
212
+ # comes in *after* the PROC returns. That is, all threads send stats
213
+ # when all threads are returned, then the supervisor returns.
214
+ # while True:
215
+ # try:
216
+ # msg = to_main_q.get(block=True, timeout=2.0)
217
+ # if isinstance(msg, list):
218
+ # _s += 1
219
+ # stats.add_tds(msg)
220
+ # if _s >= active_connections:
221
+ # break
222
+ # else:
223
+ # logger.error("Timed out, quitting")
224
+ # sys.exit(1)
225
+
226
+ # except queue.Empty:
227
+ # break
218
228
 
219
229
  # now that we have all stat reports, calculate the stats one last time.
220
230
  report = stats.calculate_stats(active_connections, end_time)
@@ -478,6 +488,7 @@ def run(
478
488
  active_connections -= 1
479
489
  elif msg == "proc_returned":
480
490
  returned_procs += 1
491
+ logger.info(f"Stopped processes: {returned_procs}/{procs} ")
481
492
  elif msg == "task_done":
482
493
  returned_threads += 1
483
494
  except queue.Empty:
@@ -580,7 +591,7 @@ def run(
580
591
  report_time += FREQUENCY
581
592
 
582
593
  # pause briefly to prevent the loop from overheating the CPU
583
- time.sleep(0.1)
594
+ time.sleep(.001)
584
595
 
585
596
  gracefully_shutdown()
586
597
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dbworkload"
3
- version = "0.8.2"
3
+ version = "0.8.3"
4
4
  description = "Workload framework"
5
5
  authors = ["Fabio Ghirardello"]
6
6
  license = "GPLv3+"
File without changes
File without changes