Pylons / waitress

Waitress - A WSGI server for Python 3
https://docs.pylonsproject.org/projects/waitress/en/latest/
Other
1.44k stars 164 forks source link

Waitress hangs #296

Closed mnikolovski closed 4 years ago

mnikolovski commented 4 years ago

Hi there team,

1) We are hosting our py module on Windows Server with the following configuration: serve(app, host="local.api.foo.bar", port=5000, threads=1000, connection_limit=1000, channel_timeout=1200, asyncore_use_poll=True)

2) The module is called via CMD: python server.py

Result: After some time the server hangs and if I press a key down/up/any it will continue processing the requests that were in the queue.

What could be the issue? - We are using this "internal API" for CPU heavy tasks.

Thank you for your help.

digitalresistor commented 4 years ago

I have no idea... could you try attaching the python debugger and seeing where it is hung at the time? Waitress itself doesn't have any code in it that would wait for a keypress of any sort.

Also, a 1000 threads with Python is probably not going to give the additional throughput you are looking for, each thread will likely be blocked waiting for whatever thread is currently executing due to the global interpreter lock.

mnikolovski commented 4 years ago

I believe I was able to find a solution. Instead of running a Waitress in CMD(admin), I have set up a scheduled task to run at startup. This task run Waitress under a service account. In the past two days, there weren't any issues.

In case someone runs into the same problem, feel free to use the scheduled task configuration.

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2020-05-15T14:58:35</Date>
  </RegistrationInfo>
  <Triggers>
    <BootTrigger>
      <StartBoundary>2020-05-15T14:58:00</StartBoundary>
      <Enabled>true</Enabled>
    </BootTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-18</UserId>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>true</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
    <Priority>7</Priority>
    <RestartOnFailure>
      <Interval>PT1M</Interval>
      <Count>10</Count>
    </RestartOnFailure>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\APP\server.bat</Command>
      <WorkingDirectory>C:\APP</WorkingDirectory>
    </Exec>
  </Actions>
</Task>

Thank you for your pointers.

digitalresistor commented 4 years ago

That sounds like the "Quick Edit" functionality that was introduced in the Cmd prompt. See this post for how to disable that functionality: https://stackoverflow.com/questions/33883530/why-is-my-command-prompt-freezing-on-windows-10

Glad you got it sorted. Closing this issue now!