Tuesday, January 26, 2021
1 change · master
Resolved issues and error corrections
This fixes a shutdown delay that could occur when users had browser sessions waiting for live updates. Odoo now wakes those waiting requests during server shutdown, helping the system stop promptly instead of waiting up to 50 seconds.
Original PR description
Start odoo in threading mode with bus installed. Login in the browser using any internal user. Make sure the browser call the /longpolling/poll uri. While the browser is waiting for a response, stop…
Start odoo in threading mode with bus installed. Login in the browser using any internal user. Make sure the browser call the /longpolling/poll uri. While the browser is waiting for a response, stop the server. The server takes up to 50 seconds to stop. When started in threading mode, a request to /longpolling/poll is served by a casual http thread. It searches for messages enqueued in the bus and returns them. If there are no message for the user in the queue yet, it creates a `threading.Event`, attach it to the user in a shared dictionnary and `wait()` on it with a timeout of 50 secondes (hardcoded value). When the bus thread (the one responsible to listen on the database) receives new messages, it `set()` the events which resume any http thread that was waiting. Because when we stop the server, there is no way to server new requests, there are no way new messages arrive in the bus. All the threads that were waiting for a new message will just wait until the event timeouts which slow down the shutdown of the server. Now we actively `set()` all events in order to resume all those workers when we stop the server. The `ImDispatch.poll` signature has been changed too so it is possible to change (via code) the hardcoded default. The function was using the object referenced by `TIMEOUT` at the time the function was defined, using `timeout None` then `if None: timeout=TIMEOUT` ensure we lookup the variable. Description of the issue/feature this PR addresses: Current behavior before PR: Desired behavior after PR is merged: -- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr