Ejemplo n.º 1
0
	def process_request(self, request, client_address):
		# The #reqcheck lock is used by some threads to block requests
		# Grab it to make sure none of those threads have it, and then add this request
		# to 'currentRequests' to prevent those threads from starting
		with getLock('#reqcheck'):
			self.totalRequests += 1
			self.currentRequests.inc()
		return super(HTTPServer, self).process_request(request, client_address)
Ejemplo n.º 2
0
	def block_requests(self, expected = 0):
		from Log import console
		lock = getLock('#reqcheck')
		lock.acquire()
		self.currentRequests -= expected
		while True:
			if self.currentRequests.count == 0:
				self.currentRequests += expected
				return lock
			lock.release()
			sleep(.1)
			lock.acquire()
Ejemplo n.º 3
0
import signal
import socket
import sys
from threading import currentThread

os.chdir(dirname(abspath(__file__)))
seed()

from HTTPServer import LoadingServer
preServer = LoadingServer()
preServer.serve_bg()

# We give stasis a single lock for all DiskMaps, but there will only be one DiskMap
from rorn.Lock import getLock, setStackRecording
from stasis.Lock import setMutexProvider
setMutexProvider(lambda: getLock('#stasis'))

from Options import option, parse as parseOptions
parseOptions()
Update.check()
if option('lock-tracking'):
	setStackRecording(True)

from stasis.Singleton import set as setDB
from stasis.DiskMap import DiskMap
from LoadValues import dbFilename
def cacheLog(table):
	sys.__stdout__.write("[%s] [%s] %s\n" % (datetime.now().replace(microsecond = 0), 'stasis', "Backfilling table: %s" % table))
setDB(DiskMap(dbFilename, cache = True, nocache = ['log', 'sessions'], cacheNotifyFn = cacheLog))

from LoadValues import bricked