Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/DIRAC/Core/DISET/ServiceReactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def __acceptIncomingConnection(self, svcName=False):
services at the same time
"""
sel = self.__getListeningSelector(svcName)
throttleExpires = None
while self.__alive:
clientTransport = None
try:
Expand All @@ -223,12 +224,19 @@ def __acceptIncomingConnection(self, svcName=False):
gLogger.warn(f"Client connected from banned ip {clientIP}")
clientTransport.close()
continue
# Handle throttling
if self.__services[svcName].wantsThrottle and throttleExpires is None:
throttleExpires = time.time() + THROTTLE_SERVICE_SLEEP_SECONDS
if throttleExpires:
if time.time() > throttleExpires:
throttleExpires = None
else:
gLogger.warn("Rejecting client due to throttling", str(clientTransport.getRemoteAddress()))
clientTransport.close()
continue
# Handle connection
self.__stats.connectionStablished()
self.__services[svcName].handleConnection(clientTransport)
while self.__services[svcName].wantsThrottle:
gLogger.warn("Sleeping as service requested throttling", svcName)
time.sleep(THROTTLE_SERVICE_SLEEP_SECONDS)
# Renew context?
now = time.time()
renewed = False
Expand Down
Loading