Skip to content

Commit

Permalink
new http client and raw client
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Sep 9, 2015
1 parent 6fc53de commit ba5d1fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/netius/extra/proxy_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,15 @@ def __init__(
robin = dict(),
smart = netius.common.PriorityDict()
)
self.occupied = 0
self.balancer_m = getattr(self, "balancer_" + self.strategy)
self.acquirer_m = getattr(self, "acquirer_" + self.strategy)
self.releaser_m = getattr(self, "releaser_" + self.strategy)

def info_dict(self, full = False):
info = netius.servers.ProxyServer.info_dict(self, full = full)
info.update(
strategy = self.strategy,
occupied = self.occupied
reuse = self.reuse,
strategy = self.strategy
)
return info

Expand Down Expand Up @@ -320,7 +319,6 @@ def balancer_smart(self, values):
return prefix, (prefix, queue)

def acquirer(self, state):
self.occupied += 1
self.acquirer_m(state)

def acquirer_robin(self, state):
Expand All @@ -335,12 +333,12 @@ def acquirer_smart(self, state):

def releaser(self, state):
self.releaser_m(state)
self.occupied -= 1

def releaser_robin(self, state):
pass

def releaser_smart(self, state):
if not state: return
prefix, queue = state
sorter = queue[prefix]
sorter[0] -= 1
Expand All @@ -350,12 +348,12 @@ def releaser_smart(self, state):
def _on_prx_message(self, client, parser, message):
_connection = parser.owner
state = _connection.state if hasattr(_connection, "state") else None
if state: self.releaser(state); _connection.state = None
self.releaser(state); _connection.state = None
netius.servers.ProxyServer._on_prx_message(self, client, parser, message)

def _on_prx_close(self, client, _connection):
state = _connection.state if hasattr(_connection, "state") else None
if state: self.releaser(state); _connection.state = None
self.releaser(state); _connection.state = None
netius.servers.ProxyServer._on_prx_close(self, client, _connection)

if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion src/netius/servers/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def info_dict(self, full = False):
info.update(
throttle = self.throttle,
max_pending = self.max_pending,
min_pending = self.min_pending
min_pending = self.min_pending,
http_client = self.http_client.info_dict(),
raw_client = self.raw_client.info_dict()
)
return info

Expand Down

0 comments on commit ba5d1fa

Please sign in to comment.