本文整理汇总了Python中exaproxy.util.log.logger.Logger.warning方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.warning方法的具体用法?Python Logger.warning怎么用?Python Logger.warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exaproxy.util.log.logger.Logger
的用法示例。
在下文中一共展示了Logger.warning方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RedirectorManager
# 需要导入模块: from exaproxy.util.log.logger import Logger [as 别名]
# 或者: from exaproxy.util.log.logger.Logger import warning [as 别名]
#.........这里部分代码省略.........
thread.join()
self.worker = {}
def _oldest (self):
"""find the oldest worker"""
oldest = None
past = time.time()
for wid in set(self.worker):
creation = self.worker[wid].creation
if creation < past and wid not in self.closing:
past = creation
oldest = self.worker[wid]
return oldest
def provision (self):
"""manage our workers to make sure we have enough to consume the queue"""
if not self.running:
return
num_workers = len(self.worker)
# bad we are bleeding workers !
if num_workers < self.low:
self.log.info("we lost some workers, respawing %d new workers" % (self.low-num_workers))
self.spawn(self.low-num_workers)
size = self.queue.qsize()
# we need more workers
if size >= num_workers:
# nothing we can do we have reach our limit
if num_workers >= self.high:
self.log.warning("help ! we need more workers but we reached our ceiling ! %d request are queued for %d processes" % (size,num_workers))
return
# try to figure a good number to add ..
# no less than one, no more than to reach self.high, lower between self.low and a quarter of the allowed growth
nb_to_add = int(min(max(1,min(self.low,(self.high-self.low)/4)),self.high-num_workers))
self.log.warning("we are low on workers adding a few (%d), the queue has %d unhandled url" % (nb_to_add,size))
self.spawn(nb_to_add)
def deprovision (self):
"""manage our workers to make sure we have enough to consume the queue"""
if not self.running:
return
size = self.queue.qsize()
num_workers = len(self.worker)
# we are now overprovisioned
if size < 2 and num_workers > self.low:
self.log.info("we have too many workers (%d), stopping the oldest" % num_workers)
# if we have to kill one, at least stop the one who had the most chance to memory leak :)
worker = self._oldest()
if worker:
self.reap(worker.wid)
def request(self, client_id, peer, request, source):
return self.queue.put((client_id,peer,request,source,False))
def getDecision(self, box):
# NOTE: reads may block if we send badly formatted data
try:
r_buffer = box.read(3)
while r_buffer.isdigit():
r_buffer += box.read(1)
示例2: RedirectorManager
# 需要导入模块: from exaproxy.util.log.logger import Logger [as 别名]
# 或者: from exaproxy.util.log.logger.Logger import warning [as 别名]
#.........这里部分代码省略.........
"""tell all our worker to stop reading the queue and stop"""
for wid in self.worker:
self.reap(wid)
self.worker = {}
def _oldest (self):
"""find the oldest worker"""
oldest = None
past = time.time()
for wid in set(self.worker):
creation = self.worker[wid].creation
if creation < past and wid not in self.stopping:
past = creation
oldest = wid
return oldest
def provision (self):
"""manage our workers to make sure we have enough to consume the queue"""
size = self.queue.qsize()
num_workers = len(self.worker)
# bad we are bleeding workers !
if num_workers < self.low:
self.log.info("we lost some workers, respawing %d new workers" % (self.low - num_workers))
self.spawn(self.low - num_workers)
# we need more workers
if size >= num_workers:
# nothing we can do we have reach our limit
if num_workers >= self.high:
self.log.warning("help ! we need more workers but we reached our ceiling ! %d request are queued for %d processes" % (size,num_workers))
return
# try to figure a good number to add ..
# no less than one, no more than to reach self.high, lower between self.low and a quarter of the allowed growth
nb_to_add = int(min(max(1,min(self.low,(self.high-self.low)/4)),self.high-num_workers))
self.log.warning("we are low on workers adding a few (%d), the queue has %d unhandled url" % (nb_to_add,size))
self.spawn(nb_to_add)
def deprovision (self):
"""manage our workers to make sure we have enough to consume the queue"""
size = self.queue.qsize()
num_workers = len(self.worker)
# we are now overprovisioned
if size < 2 and num_workers > self.low:
self.log.info("we have too many workers (%d), stopping the oldest" % num_workers)
# if we have to kill one, at least stop the one who had the most chance to memory leak :)
wid = self._oldest()
if wid:
self.stopWorker(wid)
def acquire (self):
if self.available:
identifier = self.available.pop()
worker = self.worker[identifier]
else:
worker = None
return worker
示例3: Supervisor
# 需要导入模块: from exaproxy.util.log.logger import Logger [as 别名]
# 或者: from exaproxy.util.log.logger.Logger import warning [as 别名]
#.........这里部分代码省略.........
count_saturation = 0
count_interface = 0
while True:
count_second = (count_second + 1) % self.second_frequency
count_minute = (count_minute + 1) % self.minute_frequency
count_saturation = (count_saturation + 1) % self.saturation_frequency
count_interface = (count_interface + 1) % self.interface_frequency
try:
if self._pdb:
self._pdb = False
import pdb
pdb.set_trace()
# check for IO change with select
status = self.reactor.run()
if status is False:
self._shutdown = True
# must follow the reactor so we are sure to go through the reactor at least once
# and flush any logs
if self._shutdown:
self._shutdown = False
self.shutdown()
break
elif self._reload:
self._reload = False
self.reload()
elif self._refork:
self._refork = False
self.signal_log.warning('refork not implemented')
# stop listening to new connections
# refork the program (as we have been updated)
# just handle current open connection
if self._softstop:
if self._listen == False:
self.proxy.rejecting()
self._listen = None
if self.client.softstop():
self._shutdown = True
# only change listening if we are not shutting down
elif self._listen is not None:
if self._listen:
self._shutdown = not self.proxy.accepting()
self._listen = None
else:
self.proxy.rejecting()
self._listen = None
if self._toggle_debug:
self._toggle_debug = False
self.log_writer.toggleDebug()
if self._decrease_spawn_limit:
count = self._decrease_spawn_limit
self.redirector.decreaseSpawnLimit(count)
self._decrease_spawn_limit = 0
if self._increase_spawn_limit:
示例4: poll
# 需要导入模块: from exaproxy.util.log.logger import Logger [as 别名]
# 或者: from exaproxy.util.log.logger.Logger import warning [as 别名]
def poll(self):
try:
res = self.master.control(None, self.max_events, self.speed)
except EnvironmentError, e:
if e.errno != errno.EINTR:
log.critical('KQueue master poller - unexpected error')
raise
log.warning('KQueue master poller - got EINTR, ignoring it.')
res = []
response = {}
else:
# response['poller1']=[] ; response['poller2']=[] etc.
response = dict((name, []) for (name, _, _, _) in self.pollers.values())
if len(res) == self.max_events:
log.warning("polled max_events from master kqueue")
for events in res:
fd = events.ident
name, poller, sockets, fdtosock = self.pollers[fd]
events = poller.control(None, self.max_events, 0)
if len(events) == self.max_events:
log.warning("polled max_events from queue %s" % name)
for sock_events in events:
sock_fd = sock_events.ident
try:
response[name].append(fdtosock[sock_fd])
except KeyError: