catch KeyboardInterrupt
This commit is contained in:
parent
0c11b0293c
commit
9af55c9b76
@ -16,6 +16,6 @@ try:
|
||||
for message in consumer:
|
||||
DATETIMES.append(datetime.now())
|
||||
consumer.close()
|
||||
except Exception:
|
||||
except KeyboardInterrupt:
|
||||
consumer.close()
|
||||
print(DATETIMES)
|
||||
|
@ -11,5 +11,5 @@ try:
|
||||
binstring = string.encode('UTF-8')
|
||||
while True:
|
||||
producer.send('test', binstring)
|
||||
except Exception:
|
||||
except KeyboardInterrupt:
|
||||
producer.close()
|
||||
|
@ -22,6 +22,6 @@ try:
|
||||
channel.basic_qos(prefetch_count=1)
|
||||
channel.basic_consume(queue=queue_name, on_message_callback=callback, auto_ack=True)
|
||||
channel.start_consuming()
|
||||
except Exception:
|
||||
except KeyboardInterrupt:
|
||||
connection.close()
|
||||
print(DATETIMES)
|
||||
|
@ -10,5 +10,5 @@ try:
|
||||
binstring = string.encode('UTF-8')
|
||||
while True:
|
||||
channel.basic_publish(exchange="test",routing_key="test",body=binstring)
|
||||
except Exception:
|
||||
except KeyboardInterrupt:
|
||||
connection.close()
|
||||
|
@ -16,7 +16,6 @@ try:
|
||||
while True:
|
||||
m = socket.recv_string()
|
||||
DATETIMES.append(datetime.now())
|
||||
except Exception as e:
|
||||
print(e)
|
||||
except KeyboardInterrupt:
|
||||
socket.close()
|
||||
print(DATETIMES)
|
@ -14,5 +14,5 @@ msg_body = "a" * n
|
||||
try:
|
||||
while True:
|
||||
socket.send_string(f"test {msg_body}")
|
||||
except Exception:
|
||||
except KeyboardInterrupt:
|
||||
socket.close()
|
Loading…
Reference in New Issue
Block a user