while True:
try:
queries_semaphore.acquire()
query = queries.pop(0)
# Do some stuff ...
info('Query executed: `%s\'' % str(query))
except KeyboardInterrupt:
okay('quit')
break
The problem is that KeyboardInterrupt
is raised only after queries_semaphore.acquire()
returns, so a user isn't able to break the program with Ctrl-C. What's a good solution in this case?