On Thu, Mar 12, 2020 at 10:58 PM Velu Narasimman <
velava...@gmail.com> wrote:
> That ajax call is failing sometimes. But the RuntimeError occurs even if the ajax call is success. I found the error is logged in log file.
>
> Server side code below
>
> if req.args.get('change'):
> try:
> accounts = [token.split('|')
> for token in get_list_on_scalar(req.args.get('user_roles'))
> if token]
> for username, role in accounts:
> userrole = req.args.get("new_roles").split(',');
> if not userrole:
> add_warning(req, "There was some problem in getting role preference for user - %s, failed to proceed." % username)
> errors.append("There was some problem in getting role preference for user - %s, failed to proceed." % username)
> else:
> # account_manager.modify_role(req, username, userrole)
> # add_notice(req, "The user roles are updated")
> # notices.append("The user - %s role %s have been updated"% (username, ','.join(userrole)))
> notices.append("Role of user - '%s' is updated as '%s'"% (username, ','.join(userrole)))
> data['notices'] = notices
> data['errors'] = errors
> message = "The user - %s role %s have been updated" % (username, userrole)
> EventLogManagement(self.env).log_event(req.authname, self.env.project_name, Modules.ADMIN, message, req.remote_addr, Keys.INFO)
> self.respond(req, data) # <=== 1st call
>
> except:
> (self.log.debug(traceback.format_exception(*sys.exc_info())))
> self.respond(req, data) # <=== 2nd call
The respond() method is called twice. It means Request.end_headers()
is called twice via Request.write().
RequestDone shouldn't be caught.
> except:
> (self.log.debug(traceback.format_exception(*sys.exc_info())))
The except block should be removed or the exception should be re-raise
like this:
except:
(self.log.debug(traceback.format_exception(*sys.exc_info())))
raise # <== add this line
Also, the following line:
(self.log.debug(traceback.format_exception(*sys.exc_info())))
could be:
self.log.debug('Exception caught', exc_info=True)
--
Jun Omae <
jun...@gmail.com> (大前 潤)