[FIX] server.py: resource is not available on Windows

Rev. dcb56412d6
introduces limits for the threadedserver

It uses `resource` to set the hard limit,
but unfortunately `resource` is not available on Windows.

As in the GeventServer, we therefore set the resource
hard limit within a `if os.name == 'posix'` block,
as in rev.
c68b41bff2
This commit is contained in:
Denis Ledoux
2018-10-16 12:14:46 +02:00
parent f472ea705a
commit b34b7d4270
+2 -3
View File
@@ -341,13 +341,12 @@ class ThreadedServer(CommonServer):
signal.signal(signal.SIGXCPU, self.signal_handler)
signal.signal(signal.SIGQUIT, dumpstacks)
signal.signal(signal.SIGUSR1, log_ormcache_stats)
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
resource.setrlimit(resource.RLIMIT_AS, (config['limit_memory_hard'], hard))
elif os.name == 'nt':
import win32api
win32api.SetConsoleCtrlHandler(lambda sig: self.signal_handler(sig, None), 1)
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
resource.setrlimit(resource.RLIMIT_AS, (config['limit_memory_hard'], hard))
test_mode = config['test_enable'] or config['test_file']
if test_mode or (config['http_enable'] and not stop):
# some tests need the http deamon to be available...