This is an automated email from the ASF dual-hosted git repository. chug pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push: new 8e5a6b0 DISPATCH-1304: authservice.py fail at shutdown - improvement 8e5a6b0 is described below commit 8e5a6b024110dc43d76ada9c1fed5a9cb6b95f27 Author: Chuck Rolke <c...@apache.org> AuthorDate: Thu Mar 28 14:55:50 2019 -0400 DISPATCH-1304: authservice.py fail at shutdown - improvement As noted by @astitcher the program was triggering bad behavior in proton by closing the listener in a signal handler. This commit invokes a proper shutdown by using flags and closing on a container event. --- tests/authservice.py.in | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/authservice.py.in b/tests/authservice.py.in index a05ad16..cf22bbb 100755 --- a/tests/authservice.py.in +++ b/tests/authservice.py.in @@ -37,6 +37,8 @@ class AuthService(MessagingHandler): self.allow('admin', '*', ['send', 'recv']) self.allow('guest', 'foo', ['send', 'recv']) self.listener = None + self.tmo = 0.1 # seconds + self.stop_req = False def allow(self, user, address, permissions): if not self.permissions.get(user): @@ -45,10 +47,10 @@ class AuthService(MessagingHandler): def on_start(self, event): self.listener = event.container.listen(self.address) + event.container.schedule(self.tmo, self) def stop(self): - if self.listener: - self.listener.close() + self.stop_req = True def on_connection_opening(self, event): if self.permissions.get(event.transport.user): @@ -62,6 +64,15 @@ class AuthService(MessagingHandler): symbol('address-authz'): {} } + def on_timer_task(self, event): + if self.stop_req: + if self.listener: + self.listener.close() + else: + sys.exit(0) + else: + event.reactor.schedule(self.tmo, self) + parser = optparse.OptionParser(usage="usage: %prog [options]", description="test authentication and authorization service") parser.add_option("-a", "--address", default="localhost:55671", @@ -75,13 +86,10 @@ if opts.config: print('set sasl config path to %s' % opts.config) handler = AuthService(opts.address) + def sigterm_handler(_signo, _stack_frame): - #sys.exit(0) handler.stop() signal.signal(signal.SIGTERM, sigterm_handler) -try: - Container(handler).run() -except: - pass +Container(handler).run() --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org