Thank you Jun Omae. I removed one call to "respond" method and now it is 
working fine. Thanks for your help!

On Thursday, March 12, 2020 at 8:16:56 PM UTC+5:30, Jun Omae wrote:
>
> On Thu, Mar 12, 2020 at 10:58 PM Velu Narasimman <[email protected] 
> <javascript:>> 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 <[email protected] <javascript:>> (大前 潤) 
>

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/trac-users/83530853-7182-40f8-872b-740787d72bb8%40googlegroups.com.

Reply via email to