-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalbqueue.py
More file actions
30 lines (22 loc) · 774 Bytes
/
albqueue.py
File metadata and controls
30 lines (22 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import numpy as np
from collections import deque
import time
import threading
from client import Client
from client import Request
# ## Final ALBQueue
class ALBQueue(deque):
def __init__(self):
super()
def queue_length(self):
"""Current len of queue"""
return len(self)
def time_exp(self):
"""Time Taken to service Requests proportional to this"""
return sum([item.size for item in self])
def post_count(self):
"""Count of POST method Requests in Queue"""
return sum([item._method == 'POST' for item in self])
def get_count(self):
"""Count of GET method Requests in Queue"""
return sum([item._method == 'GET' for item in self])