-
Notifications
You must be signed in to change notification settings - Fork 0
/
sender.py
36 lines (32 loc) · 1.01 KB
/
sender.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pika
import json
HOST_NAME = 'localhost'
QUEUE_NAME = 'to_rust'
data = {
'answer_id': 42,
'language': 'C++',
# 'code': '#include<stdio.h>\n int main()\n {\n int a, b;\n scanf(\"%d %d\", &a, &b);\n printf(\"%d\", a+b);\n return 0;\n }\n',
'code': '#include <iostream>\nusing namespace std;\nint main() {\n int a, b;\n cin >> a >> b;\n cout << a + b;\n return 0;\n}\n',
'memory_limit': 256000000,
'time_limit': 2,
'testcases': [
{
'input': '2 3',
'output': '5'
},
{
'input': '3 4',
'output': '7'
}
]
}
for i in range(0, 10):
data.update({'answer_id': i})
payload = json.dumps(data)
connection = pika.BlockingConnection(
pika.ConnectionParameters(host=HOST_NAME))
channel = connection.channel()
channel.queue_declare(queue=QUEUE_NAME)
channel.basic_publish(exchange='', routing_key=QUEUE_NAME, body=payload)
print('Sent: ', payload)
connection.close()